This is the mail archive of the
gcc@gcc.gnu.org
mailing list for the GCC project.
GCC 4.5: "nonconstant array index in initializer" error
- From: Denis Onischenko <denis dot onischenko at gmail dot com>
- To: gcc at gcc dot gnu dot org
- Date: Thu, 23 Apr 2009 10:31:53 +0300
- Subject: GCC 4.5: "nonconstant array index in initializer" error
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:
static struct drm_ioctl_desc drm_ioctls[] = {
DRM_IOCTL_DEF(DRM_IOCTL_VERSION, drm_version, 0),
DRM_IOCTL_DEF(DRM_IOCTL_GET_UNIQUE, drm_getunique, 0),
...
where DRM_IOCTL_DEF defined as
#define DRM_IOCTL_DEF(ioctl, _func, _flags) \
[DRM_IOCTL_NR(ioctl)] = {.cmd = ioctl, .func = _func, .flags = _flags}
Just released GCC 4.4 compiles this code without errors.
Is this a bug in GCC 4.5 or the errors caused by folowing changes in GCC 4.5:
"GCC now implements C90- and C99-conforming rules for constant
expressions. This may cause warnings or errors for some code using
expressions that can be folded to a constant but are not constant
expressions as defined by ISO C"
?
If it is not a bug, is there a way to disable this conformance rules
checking with GCC 4.5 ?