16-12-2013, 05:15 PM
For rule 12.4, what definition of "constant expression" is used? If the definition is the one from the ISO C standards, that definition does not make it clear the example is compliant because a constant variable, if initialized with a constant expression "can be evaluated during translation rather than runtime".
For the record, different compilers appear to take different approaches as to whether or not a const-qualified variable meets the definition of a "constant expression".
Code:
const uint16_t c = 0xffffu;
uint16_t y = c + 1u;
For the record, different compilers appear to take different approaches as to whether or not a const-qualified variable meets the definition of a "constant expression".