public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c++/16139] New: Wrong warnings (unused variable) reported for the code provided when -Wall is used
@ 2004-06-22 15:04 kgardas at objectsecurity dot com
2004-06-22 15:30 ` [Bug c++/16139] " pinskia at gcc dot gnu dot org
` (2 more replies)
0 siblings, 3 replies; 4+ messages in thread
From: kgardas at objectsecurity dot com @ 2004-06-22 15:04 UTC (permalink / raw)
To: gcc-bugs
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
^ permalink raw reply [flat|nested] 4+ messages in thread
* [Bug c++/16139] Wrong warnings (unused variable) reported for the code provided when -Wall is used
2004-06-22 15:04 [Bug c++/16139] New: Wrong warnings (unused variable) reported for the code provided when -Wall is used kgardas at objectsecurity dot com
@ 2004-06-22 15:30 ` pinskia at gcc dot gnu dot org
2004-06-22 17:24 ` bangerth at dealii dot org
2004-06-22 18:16 ` kgardas at objectsecurity dot com
2 siblings, 0 replies; 4+ messages in thread
From: pinskia at gcc dot gnu dot org @ 2004-06-22 15:30 UTC (permalink / raw)
To: gcc-bugs
------- Additional Comments From pinskia at gcc dot gnu dot org 2004-06-22 15:30 -------
Invalid as they are not unused as the construtor gets called which might have side effects sorry.
--
What |Removed |Added
----------------------------------------------------------------------------
Status|UNCONFIRMED |RESOLVED
Resolution| |INVALID
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=16139
^ permalink raw reply [flat|nested] 4+ messages in thread
* [Bug c++/16139] Wrong warnings (unused variable) reported for the code provided when -Wall is used
2004-06-22 15:04 [Bug c++/16139] New: Wrong warnings (unused variable) reported for the code provided when -Wall is used kgardas at objectsecurity dot com
2004-06-22 15:30 ` [Bug c++/16139] " pinskia at gcc dot gnu dot org
@ 2004-06-22 17:24 ` bangerth at dealii dot org
2004-06-22 18:16 ` kgardas at objectsecurity dot com
2 siblings, 0 replies; 4+ messages in thread
From: bangerth at dealii dot org @ 2004-06-22 17:24 UTC (permalink / raw)
To: gcc-bugs
------- Additional Comments From bangerth at dealii dot org 2004-06-22 17:24 -------
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.
--
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=16139
^ permalink raw reply [flat|nested] 4+ messages in thread
* [Bug c++/16139] Wrong warnings (unused variable) reported for the code provided when -Wall is used
2004-06-22 15:04 [Bug c++/16139] New: Wrong warnings (unused variable) reported for the code provided when -Wall is used kgardas at objectsecurity dot com
2004-06-22 15:30 ` [Bug c++/16139] " pinskia at gcc dot gnu dot org
2004-06-22 17:24 ` bangerth at dealii dot org
@ 2004-06-22 18:16 ` kgardas at objectsecurity dot com
2 siblings, 0 replies; 4+ messages in thread
From: kgardas at objectsecurity dot com @ 2004-06-22 18:16 UTC (permalink / raw)
To: gcc-bugs
------- Additional Comments From kgardas at objectsecurity dot com 2004-06-22 18:16 -------
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
--
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=16139
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2004-06-22 18:16 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2004-06-22 15:04 [Bug c++/16139] New: Wrong warnings (unused variable) reported for the code provided when -Wall is used kgardas at objectsecurity dot com
2004-06-22 15:30 ` [Bug c++/16139] " pinskia at gcc dot gnu dot org
2004-06-22 17:24 ` bangerth at dealii dot org
2004-06-22 18:16 ` kgardas at objectsecurity dot com
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).