c/10450: gcc-3.2.2 produces error on initializing a structure with a constant expression
Joseph S. Myers
jsm28@cam.ac.uk
Tue Apr 22 13:36:00 GMT 2003
The following reply was made to PR c/10450; it has been noted by GNATS.
From: "Joseph S. Myers" <jsm28@cam.ac.uk>
To: niva@niisi.msk.ru
Cc: gcc-gnats@gcc.gnu.org, gcc-prs@gcc.gnu.org, gcc-bugs@gcc.gnu.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@niisi.msk.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@cam.ac.uk
More information about the Gcc-prs
mailing list