Warning C6336
Arithmetic operator has precedence over question operator, use parentheses to clarify intent
Remarks
This warning indicates a possible operator precedence problem. The '+
','-
','*
' and '/
' operators have precedence over the '?
' operator. If the precedence in the expression isn't correct, use parentheses to change the operator precedence.
Code analysis name: QUESTIONPRECEDENCE
Example
The following code generates this warning:
int Count();
void f(int flag)
{
int result;
result = Count() + flag ? 1 : 2;
// code...
}
To correct this warning, add parenthesis as shown in the following code:
int Count();
void f(int flag)
{
int result;
result = Count() + (flag ? 1 : 2);
// code...
}
See also
Feedback
https://aka.ms/ContentUserFeedback.
Coming soon: Throughout 2024 we will be phasing out GitHub Issues as the feedback mechanism for content and replacing it with a new feedback system. For more information see:Submit and view feedback for