1

In a project where my warning level is set to 4, some warnings are not detected when using the STL as implemented by MSVC12. Here's a concrete example:

#pragma warning(default:4365)
int main( int argc, char* argv[] )
{
    int fillVal = -1;
    std::vector<unsigned int> v( 5 );
    std::fill( v.begin(), v.end(), fillVal );   // (underflow) no warning
    std::fill<std::vector<unsigned int>::iterator, unsigned int>( v.begin(), v.end(), fillVal );    // (underflow) warning C4365
        return 0;
}

It looks like at the top of xutility where std::fill is, there is this code:

#pragma warning(push,3)
// contents...
#pragma warning(pop)

But how come I don't detect this warning 4365 (of level 4) when compiling my code? Is there an easy way to get the warning for the underflow in the example above?

Edit:typo

drbradock
  • 11
  • 2
  • *"how come I don't detect this warning 4365 (of level 4)"*, As you noticed, warning level has changed in xutility header, and warning would be there. – Jarod42 Aug 28 '20 at 12:57

0 Answers0