I've been working on trying to create a singly linked list in C++ on Visual Studio but keep running into this weird bug. When I test the list everything works perfectly fine in testing except when it comes to deleting the list. For some reason whenever I call delete on it, I get a popup from Visual Studio with the following messages in this order:
Debug Assertion Failed! Expression: _BLOCK_TYPE_IS_VALID(pHead->nBlockUse)
Debug Assertion Failed! Expression: _CtrilsValidHeapPointer(pUserData)
Debug Assertion Failed! Expression: _BLOCK_TYPE_IS_VALID(pHead->nBlockUse)
The way I designed the list, head is a pointer to a dummy node that does not hold any data members. Here is the code wwhich was found to be causing problems:
int main() {
SSLL<char> list;
list.push_back('A');
delete &list;
}