From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 27101 invoked by alias); 27 Oct 2007 17:17:30 -0000 Received: (qmail 27044 invoked by uid 48); 27 Oct 2007 17:17:18 -0000 Date: Sat, 27 Oct 2007 17:17:00 -0000 Subject: [Bug c++/33925] New: gcc -Waddress lost some useful warnings X-Bugzilla-Reason: CC Message-ID: Reply-To: gcc-bugzilla@gcc.gnu.org To: gcc-bugs@gcc.gnu.org From: "mec at google dot com" Mailing-List: contact gcc-bugs-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Id: List-Archive: List-Post: List-Help: Sender: gcc-bugs-owner@gcc.gnu.org X-SW-Source: 2007-10/txt/msg02400.txt.bz2 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