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: unassig...@gcc.gnu.org
        ReportedBy: xinlian...@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.

*/

Reply via email to