From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 23900 invoked by alias); 22 Apr 2003 13:36:00 -0000 Mailing-List: contact gcc-prs-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Archive: List-Post: List-Help: Sender: gcc-prs-owner@gcc.gnu.org Received: (qmail 23866 invoked by uid 71); 22 Apr 2003 13:36:00 -0000 Date: Tue, 22 Apr 2003 13:36:00 -0000 Message-ID: <20030422133600.23865.qmail@sources.redhat.com> To: nobody@gcc.gnu.org Cc: gcc-prs@gcc.gnu.org, From: "Joseph S. Myers" Subject: Re: c/10450: gcc-3.2.2 produces error on initializing a structure with a constant expression Reply-To: "Joseph S. Myers" X-SW-Source: 2003-04/txt/msg00919.txt.bz2 List-Id: The following reply was made to PR c/10450; it has been noted by GNATS. From: "Joseph S. Myers" 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