http://llvm.org/bugs/show_bug.cgi?id=10898

           Summary: extraneous parentheses warnings
           Product: clang
           Version: trunk
          Platform: PC
        OS/Version: Windows NT
            Status: NEW
          Severity: normal
          Priority: P
         Component: C++
        AssignedTo: [email protected]
        ReportedBy: [email protected]
                CC: [email protected], [email protected]


Just updated to Xcode 4.2 beta 7.

I have the following code.
int buf_plus_null = 3 + 3 + unicode() ? 2 : 0;

Produced the following warning:


warning: operator '?:' has lower
      precedence than '+'; '+' will be evaluated first [-Wparentheses]
        int buf_plus_null = 3 + 3 + unicode() ? 2 : 0;
                            ~~~~~~~~~~~~~~~~~ ^
XYZ.h:925:47: note: place parentheses around the '+'
      expression to silence this warning
        int buf_plus_null = 3 + 3 + unicode() ? 2 : 0;
                                              ^
                            (                )
XYZ.h:925:47: note: place parentheses around the '?:'
      expression to evaluate it first
        int buf_plus_null = 3 + 3 + unicode() ? 2 : 0;
                                              ^
                                    (                )


Updated the code to have the proper parentheses to the following (Suggestion
1):
int buf_plus_null = (3 + 3 + unicode()) ? 2 : 0;

The following warning is produced:
 warning: operator '?:' has lower
      precedence than '+'; '+' will be evaluated first [-Wparentheses]
        int buf_plus_null = (3 + 3 + unicode()) ? 2 : 0;
                            ~~~~~~~~~~~~~~~~~~~ ^
XYZ.h:925:49: note: place parentheses around the '+'
      expression to silence this warning
        int buf_plus_null = (3 + 3 + unicode()) ? 2 : 0;
                                                ^
                            (                  )
XYZ.h:925:49: note: place parentheses around the '?:'
      expression to evaluate it first
        int buf_plus_null = (3 + 3 + unicode()) ? 2 : 0;
                                                ^
                                     (                 )

The 2nd suggestion is syntactically incorrect, and the 1st seems un-necessarily
verbose.  Suggestion 1 also does not fix the warning.

-- 
Configure bugmail: http://llvm.org/bugs/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are on the CC list for the bug.
_______________________________________________
LLVMbugs mailing list
[email protected]
http://lists.cs.uiuc.edu/mailman/listinfo/llvmbugs

Reply via email to