help-gplusplus
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

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


From: Nikos Chantziaras
Subject: Why doesn't GCC emit "unused variable" warnings for STL classes?
Date: Fri, 05 Oct 2012 15:35:00 +0300
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:15.0) Gecko/20120913 Thunderbird/15.0.1

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?




reply via email to

[Prev in Thread] Current Thread [Next in Thread]