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 ?

Reply via email to