This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
[Bug c/22529] [3.4/4.0/4.1 Regression] Rejects valid C99 address of C99 struct in static variable in function
- From: "joseph at codesourcery dot com" <gcc-bugzilla at gcc dot gnu dot org>
- To: gcc-bugs at gcc dot gnu dot org
- Date: 17 Jul 2005 20:58:32 -0000
- Subject: [Bug c/22529] [3.4/4.0/4.1 Regression] Rejects valid C99 address of C99 struct in static variable in function
- References: <20050717190953.22529.pinskia@gcc.gnu.org>
- Reply-to: gcc-bugzilla at gcc dot gnu dot org
------- 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