public inbox for gcc-prs@sourceware.org
help / color / mirror / Atom feed
* Re: c/10450: gcc-3.2.2 produces error on initializing a structure with a constant expression
@ 2003-04-22 23:03 bangerth
  0 siblings, 0 replies; 3+ messages in thread
From: bangerth @ 2003-04-22 23:03 UTC (permalink / raw)
  To: gcc-bugs, gcc-prs, niva, nobody

Synopsis: gcc-3.2.2 produces error on initializing a structure with a constant expression

State-Changed-From-To: open->closed
State-Changed-By: bangerth
State-Changed-When: Tue Apr 22 23:03:05 2003
State-Changed-Why:
    Duplicate of 9469

http://gcc.gnu.org/cgi-bin/gnatsweb.pl?cmd=view%20audit-trail&database=gcc&pr=10450


^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: c/10450: gcc-3.2.2 produces error on initializing a structure with a constant expression
@ 2003-04-22 13:36 Joseph S. Myers
  0 siblings, 0 replies; 3+ messages in thread
From: Joseph S. Myers @ 2003-04-22 13:36 UTC (permalink / raw)
  To: nobody; +Cc: gcc-prs

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


^ permalink raw reply	[flat|nested] 3+ messages in thread

* c/10450: gcc-3.2.2 produces error on initializing a structure with a constant expression
@ 2003-04-22 10:46 niva
  0 siblings, 0 replies; 3+ messages in thread
From: niva @ 2003-04-22 10:46 UTC (permalink / raw)
  To: gcc-gnats


>Number:         10450
>Category:       c
>Synopsis:       gcc-3.2.2 produces error on initializing a structure with a constant expression
>Confidential:   no
>Severity:       non-critical
>Priority:       medium
>Responsible:    unassigned
>State:          open
>Class:          rejects-legal
>Submitter-Id:   net
>Arrival-Date:   Tue Apr 22 10:46:00 UTC 2003
>Closed-Date:
>Last-Modified:
>Originator:     Nadezhda I. Vyukova
>Release:        gcc-3.2.2
>Organization:
>Environment:
i386 (i686-pc-linux-gnu)
gcc configured with --enable-cpp --enable-languages=all
--enable-shared
>Description:
The following error message is produced when I compile
the source code (gcc -S foo.c):
foo.c:14: initializer element is not constant
foo.c:14: (near initialization for `registers_pid_1')
foo.c:14: initializer element is not constant

I think that this behaviour contradicts to C99, 6.7.8-13. And note that gcc-2.95.3 compiles this code successfully. 
>How-To-Repeat:
typedef struct t_inf_id {
  int board;
  int processor;
  int process;
  int thread;
} t_inf_id;

typedef struct inf_id {
  unsigned long machine;
  t_inf_id tid;
  int att_flag;
} inf_id;

inf_id registers_pid_1 = ((inf_id) {0, (t_inf_id) {0, 0, -1, -1}, 0}); /* Error!*/
inf_id registers_pid_2 = ((inf_id) {0, {0, 0, -1, -1}, 0}); /* OK! */
t_inf_id t_registers_pid = ((t_inf_id) {0, 0, -1, -1});     /* OK! */
>Fix:

>Release-Note:
>Audit-Trail:
>Unformatted:


^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2003-04-22 23:03 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2003-04-22 23:03 c/10450: gcc-3.2.2 produces error on initializing a structure with a constant expression bangerth
  -- strict thread matches above, loose matches on Subject: below --
2003-04-22 13:36 Joseph S. Myers
2003-04-22 10:46 niva

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).