This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
Re: Gcc 3.2 duplicated initializers regression
- From: "Joseph S. Myers" <jsm28 at cam dot ac dot uk>
- To: Andi Kleen <ak at suse dot de>
- Cc: Jan Hubicka <jh at suse dot cz>, <gcc-bugs at gcc dot gnu dot org>
- Date: Sun, 22 Dec 2002 18:28:11 +0000 (GMT)
- Subject: 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