This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
[Bug c++/33515] New: Inconsistent warning about "defined but not used"
- From: "mec at google dot com" <gcc-bugzilla at gcc dot gnu dot org>
- To: gcc-bugs at gcc dot gnu dot org
- Date: 21 Sep 2007 05:57:15 -0000
- Subject: [Bug c++/33515] New: Inconsistent warning about "defined but not used"
- Reply-to: gcc-bugzilla at gcc dot gnu dot org
Consider this code:
class Alpha { public: Alpha(); };
static Alpha* a1 = new Alpha;
Should this draw a warning about a1 defined-but-not-used? gcc 4.3-20070914
gives a warning on some programs but not others. Specifically, I see the
warning if a program has an unrelated syntax error. This is odd.
mec@hollerith:~/exp-defined$ cat z2.cc
class Alpha {
public:
Alpha();
~Alpha();
private:
int i;
};
static Alpha* a1 = new Alpha;
int Beta() {
return 0;
}
mec@hollerith:~/exp-defined$ /home/mec/gcc-4.3-20070914/install/bin/g++ -Wall
-S z2.cc
mec@hollerith:~/exp-defined$ cat z3.cc
class Alpha {
public:
Alpha();
~Alpha();
private:
int i;
};
static Alpha* a1 = new Alpha;
int Beta() {
return x;
}
mec@hollerith:~/exp-defined$ /home/mec/gcc-4.3-20070914/install/bin/g++ -Wall
-S z3.cc
z3.cc: In function 'int Beta()':
z3.cc:12: error: 'x' was not declared in this scope
z3.cc: At global scope:
z3.cc:9: warning: 'a1' defined but not used
mec@hollerith:~/exp-defined$
--
Summary: Inconsistent warning about "defined but not used"
Product: gcc
Version: 4.3.0
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: c++
AssignedTo: unassigned at gcc dot gnu dot org
ReportedBy: mec at google dot com
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=33515