How to make std::vector’s operator[] compile doing bounds checking in DEBUG but not in RELEASE

Visual Studio 2005 and 2008 already do bounds-checking on operator[] by default, in both debug and release builds.

The macro to control this behavior is _SECURE_SCL. Set it to 0 to disable bounds-checking.

Their current plan in VS2010 is to disable bounds-checking by default in release builds, but keep it on in debug. (The macro is also getting renamed to _ITERATOR_DEBUG_LEVEL. I don’t know if there’s any formal documentation available on it yet, but it has been mentioned here and here)

Leave a Comment