Linus Torvalds writes: (Summary) wrote:
I actually really wish that were true, and that it would always be considered an ICE.
considered an ICE.
But it's not, as you also found out.
But it's not, as you also found out.
This exact problem is why we had to come up with that crazy alternative test for an actual integer constant expression. Instead of doing the integer constant expression testing early (before inlining etc), you do it later, but you carry along a bit in the expression that says "was this expression actually _syntactically_ an I-C-E?"
I-C-E?"
And btw, I hate how stupid gcc is about "constant size arrays but acts as a VLA because it wasn't an integer-constant-expression size" things.
things.
Your code generation example really is a sad sad example of it.
[...]
__builtin_constant_p to return true.I actually really wish that were true, and that it would always be considered an ICE.
considered an ICE.
But it's not, as you also found out.
But it's not, as you also found out.
This exact problem is why we had to come up with that crazy alternative test for an actual integer constant expression. Instead of doing the integer constant expression testing early (before inlining etc), you do it later, but you carry along a bit in the expression that says "was this expression actually _syntactically_ an I-C-E?"
I-C-E?"
And btw, I hate how stupid gcc is about "constant size arrays but acts as a VLA because it wasn't an integer-constant-expression size" things.
things.
Your code generation example really is a sad sad example of it.