This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
[Bug c++/33925] New: gcc -Waddress lost some useful warnings
- From: "mec at google dot com" <gcc-bugzilla at gcc dot gnu dot org>
- To: gcc-bugs at gcc dot gnu dot org
- Date: 27 Oct 2007 17:17:18 -0000
- Subject: [Bug c++/33925] New: gcc -Waddress lost some useful warnings
- Reply-to: gcc-bugzilla at gcc dot gnu dot org
gcc -Waddress got a little bit worse between gcc 4.0.4 and gcc 4.1.2. It would
be useful to get this warning, especially for C++ inline methods.
mec@hollerith:~/exp-address$ cat z2.cc
extern bool Alpha();
inline bool Beta(bool b) { return b; }
class MyClass { public: static bool MyMethod(bool b) { return b; } };
bool Gamma() {
if (Alpha) {
if (Beta) {
if (MyClass::MyMethod) {
return true;
}
}
}
return false;
}
mec@hollerith:~/exp-address$ /home/mec/gcc-4.0.4/install/bin/g++ -Wall -O2 -S
z2.cc
z2.cc: In function 'bool Gamma()':
z2.cc:6: warning: the address of 'bool Alpha()', will always evaluate as 'true'
z2.cc:7: warning: the address of 'bool Beta(bool)', will always evaluate as
'true'
z2.cc:8: warning: the address of 'static bool MyClass::MyMethod(bool)', will
always evaluate as 'true'
mec@hollerith:~/exp-address$ /home/mec/gcc-4.1.2/install/bin/g++ -Wall -O2 -S
z2.cc
z2.cc: In function 'bool Gamma()':
z2.cc:6: warning: the address of 'bool Alpha()', will always evaluate as 'true'
mec@hollerith:~/exp-address$ /home/mec/gcc-4.2.2/install/bin/g++ -Wall -O2 -S
z2.cc
z2.cc: In function 'bool Gamma()':
z2.cc:6: warning: the address of 'bool Alpha()' will always evaluate as 'true'
mec@hollerith:~/exp-address$ /home/mec/gcc-4.3-20071019/install/bin/g++ -Wall
-O2 -S z2.cc
z2.cc: In function 'bool Gamma()':
z2.cc:6: warning: the address of 'bool Alpha()' will always evaluate as 'true'
mec@hollerith:~/exp-address$
--
Summary: gcc -Waddress lost some useful warnings
Product: gcc
Version: 4.2.2
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=33925