Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Why doesn't GCC emit "unused variable" warnings for STL classes?

10 views
Skip to first unread message

Nikos Chantziaras

unread,
Oct 5, 2012, 8:35:00 AM10/5/12
to help-gp...@gnu.org
GCC doesn't produce "unused variable" warnings for 'vec' and 'str' in
the code below:

#include <vector>
#include <string>

int main()
{
std::vector<char> vec;
std::string str;
char c;
}

When compiling this with either GCC 4.6.3 or 4.7.2, I only get:

$ g++ -Wall -W main.cpp
main.cpp: In function 'int main()':
main.cpp:8:14: warning: unused variable 'c' [-Wunused-variable]

It catches 'c' as being unused, but not 'vec' and 'str'. Is this on
purpose, or did I run across a bug?


0 new messages