This is the mail archive of the gcc-bugs@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[Bug c++/16139] New: Wrong warnings (unused variable) reported for the code provided when -Wall is used


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

-- 
           Summary: Wrong warnings (unused variable) reported for the code
                    provided when -Wall is used
           Product: gcc
           Version: 3.4.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P2
         Component: c++
        AssignedTo: unassigned at gcc dot gnu dot org
        ReportedBy: kgardas at objectsecurity dot com
                CC: gcc-bugs at gcc dot gnu dot org
 GCC build triplet: i686-pc-linux-gnu
  GCC host triplet: i686-pc-linux-gnu
GCC target triplet: i686-pc-linux-gnu


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=16139


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]