[parisc-linux] possible gcc-3.2 bug?

Randolph Chung Randolph Chung <tausq@debian.org>
Tue, 15 Oct 2002 18:32:31 -0700


> > ---------------------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.

well, it's doesn't seem to be very consistent about it then...

static rwlock_t x = (rwlock_t) { { 1 }, 0 };
is ok

static rwlock_t x = { (spinlock_t) { 1 }, 0 };
is also ok

only when you have both casts does it fail...

randolph