Problem compiling with proper warning level (xlocale problem)...

Hi,

I had a problem with compiling the following piece of code with Visual C++ 8 (aka. Visual Studio 2005, Beta 2, cl.exe version 14.00.50215.44):

// C4101a.cpp
#include<string>

int main()
{
int i;// C4101
}

Compiling this with the command line "cl /WX /W2 /EHsc C4101a.cpp" should not report warning C4101 as in:

test.cpp
test.cpp(11) : error C2220: warning treated as error - no 'object' file generated
test.cpp(11) : warning C4101: 'i' : unreferenced local variable

However using /W3 option should report it.

I've tracked the problem to be caused by the inclusion of the Standard C++ string file (ie. the #include <string>). This essentiall leads to several other includes in where different #pragma warning(push)/warning(pop) directives are being used.

I've tracked the problem to be in the xlocale file, in where there are 9 #pragma warning(push) directives, but only 7 #pragma warning(pop) directives, ie. two pop's are missing! So the test code can be fixed by adding them, as in:

// C4101a.cpp
#include<string>

#pragmawarning(pop)
#pragmawarning(pop)

int main()
{
int i;// C4101
}

Hope this can help somebody fix the problem in xlocale (if it is not already been fixed in the RTM!)

/Michael

[2551 byte] By [MichaelS.] at [2007-12-17]