Based on your reading, 1,2 not a constant expression. I do not know why this is not so, I just agree with you that it is not (despite the fact that it probably should be).
6.5.2 indicates compound literals as a postfix operator. So in
(union { uint32_t i; float f; }){ 1 }.f
The operands (union { uint32_t i; float f; }){ 1 } and f refer to the operator . . This is not an arithmetic constant expression, since the first argument is a union type, but it is a constant expression.
UPDATE: I based this on a different interpretation of the standard.
My previous reasoning was that (union { uint32_t i; float f; }){ 1 }.f satisfies the criteria for a constant expression and, therefore, is a constant expression. I still think that it meets the criteria for a constant expression (6.6, clause 3), but that it is not a standard type of constant expressions (integer, arithmetic or address) and therefore is subject to a constant expression in clause 6.6 10, which allows the use of constant expressions defined by implementation.
I would also like to get to your editing. I would like to argue that the implementation of "hack" offsetof was a constant expression, but I think it is the same as above: it meets the criteria for a constant expression (and possibly a constant address), but is not an integer constant and therefore is invalid outside clause 6.6 clause.
Chris lutz
source share