A non-variable length array declaration in standard C must have an integer constant expression for its size (6.7.6.2). You are not allowed to use floating point expressions even if you cast them to an integer, with one exception - directly casting a floating point constant to integer: (int)5.5
is allowed, (int)(11.0/2)
is not (6.6).
However, this works in GCC. GCC warns about it (using a confusing message), but otherwise generates code that works as I expect it to. These are equivalent:
int a[ 6 ]; /* Standard C */
int b[ (int)6.4 ]; /* Standard C */
int c[ (int)(3.2*2) ]; /* Not standard - GCC allows it but warns */
This is fine, GCC is allowed to define rules above the default standard. In fact, since GCC is the only compiler available for my target architecture, I would not mind using this gcc extension.
My problem is: I can't find anything in the documentation that mentions that this should work. I would be grateful if someone could point me to the right place in the documentation, or - if you have some insight into this - tell me that I can't rely on it!