Search code examples
c++visual-c++stlvisual-c++-6msvcrt

Defining _CRT_SECURE_NO_WARNINGS lead to crash in vector destructor


I am working with a legacy code ported from Visual C++ 6.0 to VC++ 9.0 (2008). I disabled the secure CRT warnings using _CRT_SECURE_NO_WARNINGS pre-processor definition. But that has lead to crashes in the std::vector destructor.

Any issues in using _CRT_SECURE_NO_WARNINGS?


Solution

  • How is it crashing? This sounds more like you've got memory in one location overwriting memory in your vector, then freeing it before your vector is freed. I'd look to any place with pointers. Since you're now on a standards compliant compiler replace them with boost shared pointers or boost arrays. Anything to remove the need for pointer arithmetic where an iterator would be safer to use.