Crashes in Intel C++ Compiler, doesn't crash in Microsoft VS2005 C++ Compiler -- HELP!

jimdempseyatthecove
Total Points:
34,867
Status Points:
34,867
Black Belt
January 19, 2009 8:08 AM PST
Rate
 
#6 Reply to #5

Although the crash may not have occured, you may have trashed memory (or will trash memory shortly) by using delete [] in place of delete. delete [] requires that an array of objects be allocated to the pointer (even if it is an array of 1 element). In the array allocation, preceeding the pointer to the 1st element is a header containing an additional count information. Depending on the heap manager the count field may require a different header than the single object new allocation. If the headers are different then what would appeare to be the count field of the header (for single object allocated) may very will contain junk (some number other than 1 when interpreted as an array allocation object list for deallocation). Then if the dtor is not null then the damage will likely occure immediately. If the dtor is null and if the header for the single object allocate is a different size as the array of objects allocation header then the crash may occure some time later as you will likely be returning what would appear to be a corrupted allocation.

Jim Dempsey




Intel Software Network Forums Statistics

8292 users have contributed to 31239 threads and 99116 posts to date.
In the past 24 hours, we have 10 new thread(s) 10 new posts(s), and 21 new user(s).

In the past 3 days, the most popular thread for everyone has been huge pages on linux? The most posts were made to Pipeline buffer between stages? The post with the most views is Very amusing...  Escalated as

Please welcome our newest member amirsam7