gcc 2.96 alpha linux, initializer not constant error with enum

Robert Read rread@turbolinux.com
Mon Jan 31 02:18:00 GMT 2000

With gcc 2.96 snapshot 20000124 on alpha linux, I'm getting compiler
error "initializer element is not constant" when initializing an int*
with an enum.  Is this a bug in the compiler or a new rule?  It does
work when the enum is typecast to an int, which it probably should be
anyway, so if this it the new way of things, then perhaps just the
error message needs to be fixed.  It happens when initializing  simple variables and structs.


Here is the file:

/*begin test file*/
enum flag_type {

int * userdata = NEW; /* compiler error*/
int * userdata2 = (int)NEW; /* no compiler error*/

struct hoge {
  int * userdata ;

struct hoge hogev[]= {
  { OLD }, /* compiler error */

main () {}
/*end file*/

$ gcc -v --save-temps t2.c
Reading specs from /usr/lib/gcc-lib/alpha-turbo-linux/2.96/specs
gcc version 2.96 20000124 (experimental)
 /usr/lib/gcc-lib/alpha-turbo-linux/2.96/cpp -lang-c -v -D__GNUC__=2 -D__GNUC_MINOR__=96 -Dlinux -Dunix -D_LONGLONG -D__alpha__ -D__ELF__ -D__linux__ -D__unix__ -D_LONGLONG -D__alpha__ -D__ELF__ -D__linux -D__unix -Asystem(linux) -D__LANGUAGE_C__ -D__LANGUAGE_C -DLANGUAGE_C -Acpu(alpha) -Amachine(alpha) -D__alpha -D__alpha__ -D__alpha_ev4__ -Acpu(ev4) t2.c t2.i
GNU CPP version 2.96 20000124 (experimental) (Alpha GNU/Linux for ELF)
#include "..." search starts here:
#include <...> search starts here:
End of search list.
The following default directories have been omitted from the search path:
End of omitted list.
 /usr/lib/gcc-lib/alpha-turbo-linux/2.96/cc1 t2.i -quiet -dumpbase t2.c -version -o t2.s
GNU C version 2.96 20000124 (experimental) (alpha-turbo-linux) compiled by GNU C version 2.96 20000124 (experimental).
t2.c:7: incompatible types in initialization
t2.c:7: initializer element is not constant
t2.c:15: incompatible types in initialization
t2.c:15: initializer element is not constant
t2.c:15: (near initialization for `hogev[0].userdata')

More information about the Gcc-bugs mailing list