> The following piece of code compiles with gcc-3.0 but not with > gcc-3.2... is this a gcc bug? or is the code broken?
I would say the later. > [EMAIL PROTECTED]:~$ gcc-3.2 -c t.c > t.c: In function `foo': > t.c:12: initializer element is not constant > > (it's a simplified example of some code from the parisc-linux kernel) > > ---------------------8<----------------------- > /* compile with gcc -c foo.c */ > > typedef struct { > volatile unsigned int lock; > } spinlock_t; > > typedef struct { > spinlock_t lock; > volatile int counter; > } rwlock_t; > > void foo(void) > { > static rwlock_t x = (rwlock_t) { (spinlock_t) { 1 }, 0 }; > } Except for sizeof, cast operators in initializers for static variables can only be used to convert arithmetic types. GCC allows non-constant initializers for automatic variables. Dave -- J. David Anglin [EMAIL PROTECTED] National Research Council of Canada (613) 990-0752 (FAX: 952-6605)