This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
[Bug c++/49409] New: some possible new warnings for strange code
- From: "dcb314 at hotmail dot com" <gcc-bugzilla at gcc dot gnu dot org>
- To: gcc-bugs at gcc dot gnu dot org
- Date: Tue, 14 Jun 2011 19:15:40 +0000
- Subject: [Bug c++/49409] New: some possible new warnings for strange code
- Auto-submitted: auto-generated
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=49409
Summary: some possible new warnings for strange code
Product: gcc
Version: 4.7.0
Status: UNCONFIRMED
Severity: enhancement
Priority: P3
Component: c++
AssignedTo: unassigned@gcc.gnu.org
ReportedBy: dcb314@hotmail.com
Consider the following code
extern void g( int);
void f( int i)
{
if (i == i) // same thing compared
g( i);
if (i != i) // same thing compared
g( 2 * i);
if ((i - i) > 10) // X - X == 0, unless volatile
g( 3 * i);
if (i || i) // duplicates in ||
g( 4 * i);
if (i && i) // duplicates in &&
g( 5 * i);
}
I ran the above code through the C++ compiler, with warning flags -Wall
-Wextra and it was surprisingly silent.
Would it be worthwhile for g++ to warn about some, all or none of
the above coding errors ?