This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
gcc 2.96 alpha linux, initializer not constant error with enum
- To: gcc-bugs at gcc dot gnu dot org
- Subject: gcc 2.96 alpha linux, initializer not constant error with enum
- From: Robert Read <rread at turbolinux dot com>
- Date: Mon, 31 Jan 2000 02:18:03 -0800
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.
robert
Here is the file:
/*begin test file*/
enum flag_type {
NEW,
OLD
};
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:
/usr/local/include
/usr/lib/gcc-lib/alpha-turbo-linux/2.96/include
/usr/include
End of search list.
The following default directories have been omitted from the search path:
/usr/lib/gcc-lib/alpha-turbo-linux/2.96/../../../../include/g++-3
/usr/lib/gcc-lib/alpha-turbo-linux/2.96/../../../../alpha-turbo-linux/include
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')