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. [EMAIL PROTECTED]:~/exp-defined$ cat z2.cc class Alpha { public: Alpha(); ~Alpha(); private: int i; }; static Alpha* a1 = new Alpha; int Beta() { return 0; } [EMAIL PROTECTED]:~/exp-defined$ /home/mec/gcc-4.3-20070914/install/bin/g++ -Wall -S z2.cc [EMAIL PROTECTED]:~/exp-defined$ cat z3.cc class Alpha { public: Alpha(); ~Alpha(); private: int i; }; static Alpha* a1 = new Alpha; int Beta() { return x; } [EMAIL PROTECTED]:~/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 [EMAIL PROTECTED]:~/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