public inbox for gcc-prs@sourceware.org
help / color / mirror / Atom feed
* c/7946: -std=gnu99 and casted empty srtuct initializers
@ 2002-09-17  6:26 marcus
  0 siblings, 0 replies; 2+ messages in thread
From: marcus @ 2002-09-17  6:26 UTC (permalink / raw)
  To: gcc-gnats; +Cc: bug-hurd


>Number:         7946
>Category:       c
>Synopsis:       -std=gnu99 and casted empty srtuct initializers
>Confidential:   no
>Severity:       serious
>Priority:       medium
>Responsible:    unassigned
>State:          open
>Class:          rejects-legal
>Submitter-Id:   net
>Arrival-Date:   Tue Sep 17 06:26:01 PDT 2002
>Closed-Date:
>Last-Modified:
>Originator:     Marcus Brinkmann
>Release:        gcc (GCC) 3.2 (20020809) Debian prerelease
>Organization:
>Environment:
i386-gnu
>Description:
This bug only occurs with -std=gnu99.

Initializing an empty struct with an empty struct does not
work if the empty struct is explicitely casted to the struct
type.  GCC bails out with "initializer element not constant"
>How-To-Repeat:
Compile the following code with "gcc -std=gnu99":

typedef struct { } foo_t;

/* This one works.  */
foo_t bar = { };

/* This one fails with "initializer element is not constant.  */
foo_t baz = (foo_t) { };

int
main ()
{
  return 0;
}
>Fix:

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


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

* Re: c/7946: -std=gnu99 and casted empty srtuct initializers
@ 2002-09-17  8:24 jsm28
  0 siblings, 0 replies; 2+ messages in thread
From: jsm28 @ 2002-09-17  8:24 UTC (permalink / raw)
  To: bug-hurd, gcc-bugs, gcc-prs, jsm28, marcus, nobody

Synopsis: -std=gnu99 and casted empty srtuct initializers

State-Changed-From-To: open->closed
State-Changed-By: jsm28
State-Changed-When: Tue Sep 17 08:24:50 2002
State-Changed-Why:
    This is deliberate.  C99 compound literals are not
    constant expressions but unnamed variables intitialized
    in a given way.  The code you give is equivalent to
    
    foo_t compound_literal = { };
    foo_t baz = compound_literal;
    
    which of course fails.  As an allowance for existing
    code written for old GNU compound literals rather than
    C99 compound literals (the Linux kernel), this case
    is permitted in gnu89 mode but not gnu99 mode.

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


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

end of thread, other threads:[~2002-09-17 15:24 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2002-09-17  6:26 c/7946: -std=gnu99 and casted empty srtuct initializers marcus
2002-09-17  8:24 jsm28

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).