Hello, while developing MICO, I've found that gcc3.4.0 only reports some unused variables, although the code contains much more. i.e. following code: ---code----- #include <vector> #include <string> using namespace std; void foo() { bool tcpip_initiator_used = false; string tcpip_initiator_options = ""; bool tcpip_acceptor_used = false; string tcpip_acceptor_options = ""; bool tls_initiator_used = false; string tls_initiator_options = ""; bool tls_acceptor_used = false; string tls_acceptor_options = ""; string tls_certs_initiator_options = ""; string tls_certs_acceptor_options = ""; vector<pair<string, string> > client_users; vector<pair<string, string> > server_users; } int main(int argc, char* argv[]) { foo(); return 0; } -----code----- produces: $ c++ -Wall -c w1.cc w1.cc: In function `void foo()': w1.cc:9: warning: unused variable 'tcpip_initiator_used' w1.cc:11: warning: unused variable 'tcpip_acceptor_used' w1.cc:13: warning: unused variable 'tls_initiator_used' w1.cc:15: warning: unused variable 'tls_acceptor_used' $ Interesting is that it only reports bool variables as an unused. IMHO it should report all variables in foo() function as unused. Thanks, Karel
Invalid as they are not unused as the construtor gets called which might have side effects sorry.
Well, I wouldn't call it "invalid", just "infeasible". Note that all the variables you don't get warnings about have non-trivial constructors that have side effects. Sometimes, as in some patterns, a con/destructor call is the only interesting effect of a class, the variable is actually not used otherwise. To prevent warnings in these cases, the compiler can't] warn you in the cases you show. W.
OK, you have convience me enough. :-) Anyway, I have tested it also with Intel C++ 8.0 and Comeau C++ 4.3.3 and both emits the same warnings, so everything is ok... Thanks, Karel