This is the mail archive of the
gcc-prs@gcc.gnu.org
mailing list for the GCC project.
Re: c/10450: gcc-3.2.2 produces error on initializing a structurewith a constant expression
- From: "Joseph S. Myers" <jsm28 at cam dot ac dot uk>
- To: nobody at gcc dot gnu dot org
- Cc: gcc-prs at gcc dot gnu dot org,
- Date: 22 Apr 2003 13:36:00 -0000
- Subject: Re: c/10450: gcc-3.2.2 produces error on initializing a structurewith a constant expression
- Reply-to: "Joseph S. Myers" <jsm28 at cam dot ac dot uk>
The following reply was made to PR c/10450; it has been noted by GNATS.
From: "Joseph S. Myers" <jsm28 at cam dot ac dot uk>
To: niva at niisi dot msk dot ru
Cc: gcc-gnats at gcc dot gnu dot org, gcc-prs at gcc dot gnu dot org, gcc-bugs at gcc dot gnu dot org
Subject: Re: c/10450: gcc-3.2.2 produces error on initializing a structure
with a constant expression
Date: Tue, 22 Apr 2003 14:29:11 +0100 (BST)
On Tue, 22 Apr 2003 niva at niisi dot msk dot ru wrote:
> I think that this behaviour contradicts to C99, 6.7.8-13. And note that
> gcc-2.95.3 compiles this code successfully.
None of the cases you give is permitted by C99: compound literals are
unnamed variables and are never constant expressions. It's simply that a
few cases that used to be accepted as part of the GNU "constructor
expressions" extension (which shared the syntax but not the semantics of
compound literals) are for compatibility with old code still accepted in
gnu89 mode.
The standard is actually rather unclear about whether expressions of
structure or union type can initialize a subaggregate at all (as part of
initialization of an aggregate of automatic storage duration, where
constant expressions are not required): whether the object to be
initialized gets chosen according to the type of the initializer or
whether it is always the most nested scalar object that is chosen. This
may merit a DR (though for the last DR concerning lack of clarity in the
description of initializers, DR#253, the committee decided that the
standard was clear enough (but did at least say what it meant - which was
the interpretation already followed in GCC)).
--
Joseph S. Myers
jsm28 at cam dot ac dot uk