public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c/22529] New: [3.4/4.0/4.1 Regression] Rejects valid C99 address of C99 struct in static variable in function
@ 2005-07-17 19:10 pinskia at gcc dot gnu dot org
2005-07-17 19:12 ` [Bug c/22529] " pinskia at gcc dot gnu dot org
` (4 more replies)
0 siblings, 5 replies; 6+ messages in thread
From: pinskia at gcc dot gnu dot org @ 2005-07-17 19:10 UTC (permalink / raw)
To: gcc-bugs
Take the following code:
struct f1
{
int i;
};
void f(void)
{
static struct f1 *f2 = &(struct f1){1};
}
This is valid C99 at least according to both ICC and Comeau.
And we acceptted it in 3.0.4 also.
--
Summary: [3.4/4.0/4.1 Regression] Rejects valid C99 address of
C99 struct in static variable in function
Product: gcc
Version: 4.1.0
Status: UNCONFIRMED
Keywords: rejects-valid
Severity: normal
Priority: P2
Component: c
AssignedTo: unassigned at gcc dot gnu dot org
ReportedBy: pinskia at gcc dot gnu dot org
CC: gcc-bugs at gcc dot gnu dot org
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=22529
^ permalink raw reply [flat|nested] 6+ messages in thread
* [Bug c/22529] [3.4/4.0/4.1 Regression] Rejects valid C99 address of C99 struct in static variable in function
2005-07-17 19:10 [Bug c/22529] New: [3.4/4.0/4.1 Regression] Rejects valid C99 address of C99 struct in static variable in function pinskia at gcc dot gnu dot org
@ 2005-07-17 19:12 ` pinskia at gcc dot gnu dot org
2005-07-17 20:18 ` joseph at codesourcery dot com
` (3 subsequent siblings)
4 siblings, 0 replies; 6+ messages in thread
From: pinskia at gcc dot gnu dot org @ 2005-07-17 19:12 UTC (permalink / raw)
To: gcc-bugs
--
What |Removed |Added
----------------------------------------------------------------------------
Target Milestone|--- |3.4.5
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=22529
^ permalink raw reply [flat|nested] 6+ messages in thread
* [Bug c/22529] [3.4/4.0/4.1 Regression] Rejects valid C99 address of C99 struct in static variable in function
2005-07-17 19:10 [Bug c/22529] New: [3.4/4.0/4.1 Regression] Rejects valid C99 address of C99 struct in static variable in function pinskia at gcc dot gnu dot org
2005-07-17 19:12 ` [Bug c/22529] " pinskia at gcc dot gnu dot org
@ 2005-07-17 20:18 ` joseph at codesourcery dot com
2005-07-17 20:19 ` pinskia at gcc dot gnu dot org
` (2 subsequent siblings)
4 siblings, 0 replies; 6+ messages in thread
From: joseph at codesourcery dot com @ 2005-07-17 20:18 UTC (permalink / raw)
To: gcc-bugs
------- Additional Comments From joseph at codesourcery dot com 2005-07-17 20:13 -------
Subject: Re: New: [3.4/4.0/4.1 Regression] Rejects valid C99
address of C99 struct in static variable in function
On Sun, 17 Jul 2005, pinskia at gcc dot gnu dot org wrote:
> Take the following code:
> struct f1
> {
> int i;
> };
> void f(void)
> {
> static struct f1 *f2 = &(struct f1){1};
> }
>
> This is valid C99 at least according to both ICC and Comeau.
So report it as a bug in ICC and Comeau. It is exactly as valid as
struct f1
{
int i;
};
void f(void)
{
struct f1 tmp = { 1 };
static struct f1 *f2 = &tmp;
}
i.e. not at all. The address of an object of automatic storage duration
is not a constant.
--
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=22529
^ permalink raw reply [flat|nested] 6+ messages in thread
* [Bug c/22529] [3.4/4.0/4.1 Regression] Rejects valid C99 address of C99 struct in static variable in function
2005-07-17 19:10 [Bug c/22529] New: [3.4/4.0/4.1 Regression] Rejects valid C99 address of C99 struct in static variable in function pinskia at gcc dot gnu dot org
2005-07-17 19:12 ` [Bug c/22529] " pinskia at gcc dot gnu dot org
2005-07-17 20:18 ` joseph at codesourcery dot com
@ 2005-07-17 20:19 ` pinskia at gcc dot gnu dot org
2005-07-17 20:58 ` pinskia at gcc dot gnu dot org
2005-07-17 21:03 ` joseph at codesourcery dot com
4 siblings, 0 replies; 6+ messages in thread
From: pinskia at gcc dot gnu dot org @ 2005-07-17 20:19 UTC (permalink / raw)
To: gcc-bugs
------- Additional Comments From pinskia at gcc dot gnu dot org 2005-07-17 20:18 -------
That is interesting as if we move the variable declaration out of the function, it works in GCC.
--
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=22529
^ permalink raw reply [flat|nested] 6+ messages in thread
* [Bug c/22529] [3.4/4.0/4.1 Regression] Rejects valid C99 address of C99 struct in static variable in function
2005-07-17 19:10 [Bug c/22529] New: [3.4/4.0/4.1 Regression] Rejects valid C99 address of C99 struct in static variable in function pinskia at gcc dot gnu dot org
` (2 preceding siblings ...)
2005-07-17 20:19 ` pinskia at gcc dot gnu dot org
@ 2005-07-17 20:58 ` pinskia at gcc dot gnu dot org
2005-07-17 21:03 ` joseph at codesourcery dot com
4 siblings, 0 replies; 6+ messages in thread
From: pinskia at gcc dot gnu dot org @ 2005-07-17 20:58 UTC (permalink / raw)
To: gcc-bugs
------- Additional Comments From pinskia at gcc dot gnu dot org 2005-07-17 20:56 -------
I believe you that this is invalid code.
--
What |Removed |Added
----------------------------------------------------------------------------
Status|UNCONFIRMED |RESOLVED
Resolution| |INVALID
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=22529
^ permalink raw reply [flat|nested] 6+ messages in thread
* [Bug c/22529] [3.4/4.0/4.1 Regression] Rejects valid C99 address of C99 struct in static variable in function
2005-07-17 19:10 [Bug c/22529] New: [3.4/4.0/4.1 Regression] Rejects valid C99 address of C99 struct in static variable in function pinskia at gcc dot gnu dot org
` (3 preceding siblings ...)
2005-07-17 20:58 ` pinskia at gcc dot gnu dot org
@ 2005-07-17 21:03 ` joseph at codesourcery dot com
4 siblings, 0 replies; 6+ messages in thread
From: joseph at codesourcery dot com @ 2005-07-17 21:03 UTC (permalink / raw)
To: gcc-bugs
------- Additional Comments From joseph at codesourcery dot com 2005-07-17 20:58 -------
Subject: Re: [3.4/4.0/4.1 Regression] Rejects valid C99 address
of C99 struct in static variable in function
On Sun, 17 Jul 2005, pinskia at gcc dot gnu dot org wrote:
> That is interesting as if we move the variable declaration out of the
> function, it works in GCC.
That's because of 6.5.2.5#6 which defines the storage duration of compound
literals to depend on whether they are inside a function:
[#6] The value of the compound literal is that of an unnamed
object initialized by the initializer list. If the compound
literal occurs outside the body of a function, the object
has static storage duration; otherwise, it has automatic
storage duration associated with the enclosing block.
--
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=22529
^ permalink raw reply [flat|nested] 6+ messages in thread
end of thread, other threads:[~2005-07-17 20:58 UTC | newest]
Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2005-07-17 19:10 [Bug c/22529] New: [3.4/4.0/4.1 Regression] Rejects valid C99 address of C99 struct in static variable in function pinskia at gcc dot gnu dot org
2005-07-17 19:12 ` [Bug c/22529] " pinskia at gcc dot gnu dot org
2005-07-17 20:18 ` joseph at codesourcery dot com
2005-07-17 20:19 ` pinskia at gcc dot gnu dot org
2005-07-17 20:58 ` pinskia at gcc dot gnu dot org
2005-07-17 21:03 ` joseph at codesourcery dot com
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).