On Thu, Apr 23, 2009 at 1:38 PM, Denis Onischenko <denis.onische...@gmail.com> wrote: > The minimal code example is following: > > > extern unsigned int __invalid_size_argument; > #define TYPECHECK(t) ( sizeof(t) == sizeof(t[1]) ? sizeof(t) : > __invalid_size_argument ) > > static int arr[] = { > [TYPECHECK(int)] = 0, > }; > > int main() > { > return 0; > } > > > command line is: gcc test.c > > GCC 4.5.0 revision 146607 compiles this code with following errors: > test.c:5: error: nonconstant array index in initializer > test.c:5: error: (near initialization for 'arr') > > released GCC 4.4.0 compiles without any errors
A diagnostic is required in standards-conforming modes, as TYPECHECK(int) is not an "integral constant expression" (because it includes a non-constant in a potentially-evaluated operand). -- James