Re: GCC 4.5: "nonconstant array index in initializer" error

2009-04-25 Thread Denis Onischenko
> Is the kernel using this sort of non-integer-constant-expression in > bit-field widths as well?  Sizes of file-scope arrays (OK, a special case > for that was added for WINE)?  Null pointer constants (that's much more > problematic to add special cases for)?  __builtin_choose_expr conditions? > I

Re: GCC 4.5: "nonconstant array index in initializer" error

2009-04-25 Thread Joseph S. Myers
On Sat, 25 Apr 2009, Denis Onischenko wrote: > Thanks for the patch. > > There are another error while building linux kernel with GCC 4.5.0 > revision 146771. > > The minimal code for reproducing the error looks like: > > extern unsigned int __invalid_size_argument; > #define TYPECHECK(t)(

Re: GCC 4.5: "nonconstant array index in initializer" error

2009-04-25 Thread Denis Onischenko
Thanks for the patch. There are another error while building linux kernel with GCC 4.5.0 revision 146771. The minimal code for reproducing the error looks like: extern unsigned int __invalid_size_argument; #define TYPECHECK(t)( sizeof(t) == sizeof(t[1]) ? sizeof(t) : __invalid_size_argument

Re: GCC 4.5: "nonconstant array index in initializer" error

2009-04-23 Thread Miles Bader
Joe Buck writes: > The compiler is not supposed to be pedantic by default. A standards > document saying that a diagnostic is required should not be the end > of the story, especially when we're talking about important, widely > used code bases. Sure, but at least your example code seems pretty

Re: GCC 4.5: "nonconstant array index in initializer" error

2009-04-23 Thread James Dennett
On Thu, Apr 23, 2009 at 5:39 PM, Joe Buck wrote: > > On Thu, Apr 23, 2009 at 1:38 PM, Denis Onischenko >> wrote: >> > The minimal code example is following: >> > >> > >> > extern unsigned int __invalid_size_argument; >> > #define TYPECHECK(t)    ( sizeof(t) == sizeof(t[1]) ?  sizeof(t) : >> > __i

Re: GCC 4.5: "nonconstant array index in initializer" error

2009-04-23 Thread Joe Buck
On Thu, Apr 23, 2009 at 1:38 PM, Denis Onischenko > 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[] = { > >

Re: GCC 4.5: "nonconstant array index in initializer" error

2009-04-23 Thread James Dennett
On Thu, Apr 23, 2009 at 1:38 PM, Denis Onischenko 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)] =

Re: GCC 4.5: "nonconstant array index in initializer" error

2009-04-23 Thread Denis Onischenko
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.

Re: GCC 4.5: "nonconstant array index in initializer" error

2009-04-23 Thread Joseph S. Myers
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)

Re: GCC 4.5: "nonconstant array index in initializer" error

2009-04-23 Thread Denis Onischenko
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 expressi

Re: GCC 4.5: "nonconstant array index in initializer" error

2009-04-23 Thread Joseph S. Myers
On Thu, 23 Apr 2009, Denis Onischenko wrote: > The following errors appears when I tried to compile linux kernel > 2.6.30-rc2 with GCC 4.5: > > > linux-2.6/drivers/gpu/drm/drm_drv.c:59: error: nonconstant array index > in initializer > linux-2.6/drivers/gpu/drm/drm_drv.c:59: error: (near initial

GCC 4.5: "nonconstant array index in initializer" error

2009-04-23 Thread Denis Onischenko
The following errors appears when I tried to compile linux kernel 2.6.30-rc2 with GCC 4.5: linux-2.6/drivers/gpu/drm/drm_drv.c:59: error: nonconstant array index in initializer linux-2.6/drivers/gpu/drm/drm_drv.c:59: error: (near initialization for 'drm_ioctls') ... compiled code looks like this