pointer error
-
char *sendSize; sendSize = new char[10]; //on operator delete i have error during the running: //Unhandled exception at 0x77f767cd in Connect.exe: User //breakpoint. // in dbgheap.h // #define WINVER 0x0400 // I'm using VS 7. delete [] sendSize;
there must be something you must be doing between new and delete that is causing the problem with the pointer. if you overshoot the buffer you would get the error when deleting the pointer.
I'll write a suicide note on a hundred dollar bill - Dire Straits
-
char *sendSize; sendSize = new char[10]; //on operator delete i have error during the running: //Unhandled exception at 0x77f767cd in Connect.exe: User //breakpoint. // in dbgheap.h // #define WINVER 0x0400 // I'm using VS 7. delete [] sendSize;
Be sure you don't write outside the border of your allocated memory (be carefull of the end of string character ('\0') ). So this will probably produce an exception when destroying the string:
char* sendSize; sendSize = new char[10]; strcpy(sendSize,"1234567899"); //'\0'will be added to end of string
-
there must be something you must be doing between new and delete that is causing the problem with the pointer. if you overshoot the buffer you would get the error when deleting the pointer.
I'll write a suicide note on a hundred dollar bill - Dire Straits
Weird... I had that one too a while ago and it seemingly had nothing to do with pointers. This is just that there is a particular breakpoint code in executable. Can this be a compiler bug because it all went away as soon as I switched to Release build. PS. It's not an "overshoot" error. The error message sounds differently. I remember because I get it at times :)
-
Weird... I had that one too a while ago and it seemingly had nothing to do with pointers. This is just that there is a particular breakpoint code in executable. Can this be a compiler bug because it all went away as soon as I switched to Release build. PS. It's not an "overshoot" error. The error message sounds differently. I remember because I get it at times :)
You are still trashing memory outside of the array. The reason it doesn't have problems in release mode is because the CRTL doesn't have the memory checks on deallocation. All you did was turn off the error, not fix it. Tim Smith I'm going to patent thought. I have yet to see any prior art.
-
char *sendSize; sendSize = new char[10]; //on operator delete i have error during the running: //Unhandled exception at 0x77f767cd in Connect.exe: User //breakpoint. // in dbgheap.h // #define WINVER 0x0400 // I'm using VS 7. delete [] sendSize;
-
char *sendSize; sendSize = new char[10]; //on operator delete i have error during the running: //Unhandled exception at 0x77f767cd in Connect.exe: User //breakpoint. // in dbgheap.h // #define WINVER 0x0400 // I'm using VS 7. delete [] sendSize;
See the line dbgheap.h which is showing an error. It can tell you a lot about the failure. Bikram Singh
-
You are still trashing memory outside of the array. The reason it doesn't have problems in release mode is because the CRTL doesn't have the memory checks on deallocation. All you did was turn off the error, not fix it. Tim Smith I'm going to patent thought. I have yet to see any prior art.
Yup. This can be true. But the other possibility is that there actually is no error and Debug version just keeps generating that lousy exception because I'm trying to write beyond what's the end of the string (i.e. '\0') but far from being beyond the end of the allocated memory end. In such case it can be but a misunderstanding based on compiler developers' wish to warn programmer of a possible mistake. If it's an actual error then please somebody explain to me what's wrong with this code: char* ptr=new char[256]; strcpy(ptr,"123"); ptr[3]='4'; ptr[4]='\0'; delete [] char; //we get an exception here