This is the mail archive of the
mailing list for the GCC project.
Re: [PATCH] Allow compound literals in static storage duration objectinitializers
- From: "Joseph S. Myers" <jsm28 at cam dot ac dot uk>
- To: Jakub Jelinek <jakub at redhat dot com>
- Cc: <gcc-patches at gcc dot gnu dot org>
- Date: Wed, 12 Dec 2001 19:00:06 +0000 (GMT)
- Subject: Re: [PATCH] Allow compound literals in static storage duration objectinitializers
On Wed, 12 Dec 2001, Jakub Jelinek wrote:
> Note that I don't agree with !flag_isoc99, I'd think !pedantic
> would be more appropriate (or !pedantic and not -std=c99).
I don't think in C99 mode the extension makes sense, in the context of the
C99 meaning of compound literals as objects. (In C89 mode -pedantic will
of course already generate a warning for the compound literal, so no
additional warning is needed there for the extension.) Also note that
-pedantic should never add errors, only warnings; -pedantic-errors should
be needed for them to become errors. I think just allowing this in C89
mode is the best approach.
> a) handle it the same way as older gcc, which is kind of surprising
> behaviour (this done in patch below)
> b) issue an error if compound literal's array type is not unknown
> size and the size is different to the size of bracket enclosed
> c) handle it so that object gets size of the compound literal array type
If this extension were intentionally designed, clearly (c) would be
appropriate; as it is, as an allowance for old code, (a), though
surprising and of an odd design, may be best.
> 2001-12-12 Jakub Jelinek <email@example.com>
> * c-typeck.c (digest_init): Allow initializing
> static storage duration objects with compound literals.
> * doc/extend.texi (Compound literals): Document the extension.
> * testsuite/gcc.dg/gnu89-init-1.c: New test.
Joseph S. Myers