[Bug c++/52958] New: Missing warning on missed parehthesis

xinliangli at gmail dot com gcc-bugzilla@gcc.gnu.org
Thu Apr 12 22:05:00 GMT 2012


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=52958

             Bug #: 52958
           Summary: Missing warning on missed parehthesis
    Classification: Unclassified
           Product: gcc
           Version: 4.8.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c++
        AssignedTo: unassigned@gcc.gnu.org
        ReportedBy: xinliangli@gmail.com


int test(bool b, int x, int y) {
  return 42 + b ? x : y;
 }

/*

parentheses4.cpp:2:17: warning: operator '?:' has lower precedence than
'+'; '+' will be evaluated first [-Wparentheses]
 return 42 + b ? x : y;
        ~~~~~~ ^
parentheses4.cpp:2:17: note: place parentheses around the '+' expression
to silence this warning
 return 42 + b ? x : y;
               ^
        (     )
parentheses4.cpp:2:17: note: place parentheses around the '?:' expression
to evaluate it first
 return 42 + b ? x : y;
               ^
             (        )
1 warning generated.

*/



More information about the Gcc-bugs mailing list