This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
Re: c++/10086: static const int unresolved in ? : construct
- From: "Giovanni Bajo" <giovannibajo at libero dot it>
- To: <gcc-gnats at gcc dot gnu dot org>,<gcc-bugs at gcc dot gnu dot org>,<chrisk at mysticlabs dot com>,<nobody at gcc dot gnu dot org>,<gcc-prs at gcc dot gnu dot org>
- Date: Sun, 16 Mar 2003 02:02:59 +0100
- Subject: Re: c++/10086: static const int unresolved in ? : construct
http://gcc.gnu.org/cgi-bin/gnatsweb.pl?cmd=view%20audit-trail&database=gcc&p
r=10086
I'm not sure what it is going on. I know that the standard says that you
still have to define an initialized static const member (even if there is an
open defect report about this, I believe). But then, why this should work:
struct Foo
{
static const int A = 0;
};
int main(void)
{
return Foo::A;
}
This one compiles and links correctly on G++ 3.2, but it should not. The
poster reported a simple case when just defining a local variable to mirror
the contents of the static const member changes the compilation failure into
a success. IMO there is an issue here (probably related to the optimized
which is stripping away the symbol in some situations, thus avoiding the
linker error).
Giovanni Bajo