[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Re: [parisc-linux] possible gcc-3.2 bug?



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

Ok, I think I see what is going on.  "(rwlock_t) { { 1 }, 0 }" is
a compound literal (constructor expression).  GCC allows initialization
of static objects by compound literals.  This is not possible in ISO C99.

The initializer list of the compound literal must be constant.  Thus,
nesting of compound literals isn't possible.  So, when you have two
casts in the initializer you get the error.  For more info, look at
extend.texi.

Dave
-- 
J. David Anglin                                  dave.anglin@nrc.ca
National Research Council of Canada              (613) 990-0752 (FAX: 952-6605)



Reply to: