Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Definition of "constant expression"
#6
The phrase constant expression appears in italics in the MISRA C:2012 guidelines and therefore refers to an entry with the same name in the C99 standard.

The intention was that this rule should refer to expressions that did not violate either the constraints of constant expressions or exhibit undefined behaviour. The example with "const uint16_t c" was included to re-enforce this point. However, we appreciate that the amplification could have been clearer on this point and that the supporting text is incorrect.

The line
Quote:This rule does not apply to the expression c + 1 in the following compliant example as it accesses an object and therefore does not satisfy the constraints for a constant expression
Should read
Quote:This rule does not apply to the expression c + 1 in the following compliant example as it accesses an object and therefore does not satisfy the semantics for a constant expression

And in the amplification the line
Quote:This rule applies to expressions that satisfy the constraints for a constant expression, whether or not they appear in a context that requires a constant expression.
Should read
Quote:This rule applies to expressions that satisfy the constraints and semantics for a constant expression, whether or not they appear in a context that requires a constant expression.

In practice only the semantics of integer constant expression are important as the other forms of constant expressions will not be involved with unsigned integer wrap-around.
Posted by and on behalf of the MISRA C Working Group
Reply


Messages In This Thread

Forum Jump:


Users browsing this thread: 1 Guest(s)