This is the mail archive of the gcc-bugs@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: Gcc 3.2 duplicated initializers regression


On Sun, 22 Dec 2002, Andi Kleen wrote:

> struct { int a; } x = { .a = 1, .a = 2 }; 
> 
> compiles without warning/error on gcc 3.2. Earlier gcc versions (like 2.95.3) 
> correctly errored out at the duplicated initializer. 
> This looks like a frontend regression in 3.2. 

No, it's an implementation of the C99 standard requirement that
initializers can be overridden.  (This may mean increased memory
consumption in certain cases, since the whole structure or array
initializer needs to be built up in memory before it can be assembled, in
case parts are overridden, whereas before there was rather complicated
code to write out partial initializers without needing the whole
initializer in memory; that's an inevitable consequence of implementing
the standard rather than a regression.)  This (and that there's a warning
if you override an initializer with side effects) is documented in the
manual.

-- 
Joseph S. Myers
jsm28@cam.ac.uk


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]