[Bug c++/49409] New: some possible new warnings for strange code

dcb314 at hotmail dot com gcc-bugzilla@gcc.gnu.org
Tue Jun 14 19:15:00 GMT 2011


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 ?



More information about the Gcc-bugs mailing list