Export (0) Print
Expand All
Expand Minimize
This topic has not yet been rated - Rate this topic

C6336

warning C6336: arithmetic operator has precedence over question operator, use parentheses to clarify intent

This warning indicates a possible operator precedence problem. The '+','-','*' and '/' operators have precedence over the '?' operator. If the precedence in the expression is not correct, use parentheses to change the operator precedence.

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...
}
Did you find this helpful?
(1500 characters remaining)
Thank you for your feedback
Show:
© 2014 Microsoft. All rights reserved.