This is the mail archive of the
gcc@gcc.gnu.org
mailing list for the GCC project.
Re: [Fwd: GCC 4.0 bug]
- From: Andrew Pinski <pinskia at physics dot uc dot edu>
- To: patrick dot bennett at inin dot com (Patrick Bennett)
- Cc: gcc at gcc dot gnu dot org, Felix dot Wyss at inin dot com (Wyss Felix)
- Date: Fri, 28 Oct 2005 13:00:49 -0400 (EDT)
- Subject: Re: [Fwd: GCC 4.0 bug]
>
> I'm forwarding this message from a coworker.
> He ran into this regression bug with GCC 4.0.1 (it works correctly in
> 3.4.1).
> The conditional operator expression isn't handling static consts
> correctly resulting in linker errors since it is trying to resolve to
> statics that were never defined.
>
> struct Foo
> {
> static const int a = 1;
> static const int b = 2;
> };
>
>
> inline void foo(bool v)
> {
> std::cout << ((v) ? (Foo::a) : (Foo::b));
> }
This is not a bug. You still need to do:
const int Foo::a;
const int Foo::b;
For this to be valid C++.
-- Pinski