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.

C6314

warning C6314: Incorrect order of operations: bitwise-or has higher precedence than the conditional-expression operator. Add parentheses to clarify intent

This message indicates that an expression that contains a bitwise-or operator (|) was detected in the tested expression of a conditional operation (?:).

The conditional operator has lower precedence than bitwise operators. If the tested expression should contain the bitwise-or operator, then parentheses should be added around the conditional-expression.

The following code generates this warning:

int SystemState();

int f(int SignalValue)
{
  return SystemState() | (SignalValue != 0) ? 1 : 0;
}

To correct this warning, use the following code:

int SystemState();

int f(int SignalValue)
{
  return SystemState() | ((SignalValue != 0) ? 1 : 0);
} 

Community Additions

ADD
Show:
© 2015 Microsoft