The following code gives this warning: 62 C:\Dev-Cpp\Projects\gcc-test\main.cpp [Warning] unused variable 'x' If you uncomment the constructor, the warning does not appear. class Test { public: //Test() {} }; int main(int argc, char *argv[]) { Test x; return 0; } Happened on Windows 2000 SP4 with gcc-3.4.1-20040711-1, mingw- runtime-3.3 and win32api-2.5. Compiled with "-Wunused".
That's documented behavior: the warning about unused variables is only shown if the compiler can know that running con- and destructors has no side-effects. W.