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



2009/4/23 Joseph S. Myers <jos...@codesourcery.com>:
> On Thu, 23 Apr 2009, Denis Onischenko wrote:
>
>> Thanks for reply!
>>
>> DRM_IOCTL_NR is defined as
>>
>> #define _IOC_NRBITS  8
>>
>> #define _IOC_NRSHIFT 0
>> #define _IOC_NRMASK  ((1 << _IOC_NRBITS)-1)
>>
>> #define _IOC_NR(nr)        (((nr) >> _IOC_NRSHIFT) & _IOC_NRMASK)
>>
>> #define DRV_IOCTL_NR(n)            _IOC_NR(n)
>>
>>
>>
>> i.e. expands to an integer constant expression
>
> How then are its operands (DRM_IOCTL_VERSION, DRM_IOCTL_GET_UNIQUE, etc.)
> defined?
>
> You should send a complete, self-contained, minimal code example that
> reproduces the issue you see, complete with the compilation options used,
> rather than snippets without all the previous declarations they require.
> Your message needs to contain all the information needed to reproduce the
> problem without referring to any external sources.
>
> --
> Joseph S. Myers
> jos...@codesourcery.com
>

Reply via email to