Was this page helpful?
Your feedback about this content is important. Let us know what you think.
Additional feedback?
1500 characters remaining
Export (0) Print
Expand All
Important This document may not represent best practices for current development, links to downloads and other resources may no longer be valid. Current recommended version can be found here.

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.

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

Community Additions

ADD
Show:
© 2015 Microsoft