I’m working with some autoconf stuff, and there is a test that includes the following:
static int test_array [1 - 2 * !((((float)((int)((float)1.4))) == ((float)1.4)) >= 0)];
This fails with:
error: storage size of ‘test_array’ isn’t constant
but when I change this to:
static int test_array [1 - 2 * !((((int)((int)((int)1.4))) == ((int)1.4)) >= 0)];
it works fine.
I’m not very familiar with all the hacks the autotools employ, but both of these seem like the value should be determinible at compile-time to me.
Why does the first one fail?
Let us look at the standard (6.6 (6)):
(emphasis mine).
You must not cast to
floatin an integer constant expression (except in arguments tosizeofor_Alignof), thusisn’t an integer constant expression.
The number of elements of a
staticarray must be an integer constant expression evaluating to a positive integer.