C6336

Note

This article applies to Visual Studio 2015. If you're looking for the latest Visual Studio documentation, see Visual Studio documentation. We recommend upgrading to the latest version of Visual Studio. Download it here

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.

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

C++ Built-in Operators, Precedence and Associativity