vendredi 1 avril 2016

What should I set to _ITERATOR_DEBUG_LEVEL

I was digging in the std::vector::insert implementation in MSVC 2013 and I found this code:

#if _ITERATOR_DEBUG_LEVEL == 2
        if (_VICONT(_Where) != this
            || _VIPTR(_Where) < this->_Myfirst
            || this->_Mylast < _VIPTR(_Where))
            _DEBUG_ERROR("vector insert iterator outside range");
        _DEBUG_RANGE(_First, _Last);
 #endif /* _ITERATOR_DEBUG_LEVEL == 2 */

and it was disabled because _ITERATOR_DEBUG_LEVEL = 0 (Release Mode). If I switched to Debug Mode it become enabled because _ITERATOR_DEBUG_LEVEL = 2.

My questions are:

  1. Is this MSVC thing or it is a standard?
  2. Why would someone make _ITERATOR_DEBUG_LEVEL = 0 even in Release Mode. Isn't an Undefined Behavior that should be caught rather than put on silent mode!? I mean if the condition that inside that block did satisfied, it may cause many problems.

Aucun commentaire:

Enregistrer un commentaire