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: Gabriel Dos Reis <gdr at integrable-solutions dot net>
- To: "Giovanni Bajo" <giovannibajo at libero dot it>
- Cc: <gcc-gnats at gcc dot gnu dot org>, <gcc-bugs at gcc dot gnu dot org>, <chrisk at mysticlabs dot com>
- Date: 16 Mar 2003 10:28:29 +0100
- Subject: Re: c++/10086: static const int unresolved in ? : construct
- Organization: Integrable Solutions
- References: <01e601c2eb57$ca254f00$044c2a97@bagio>
"Giovanni Bajo" <giovannibajo at libero dot it> writes:
| http://gcc.gnu.org/cgi-bin/gnatsweb.pl?cmd=view%20audit-trail&database=gcc&p
| r=10086
I think arguments can be made for both sides (bug or not a bug) in
this particular case. Certainly understand what is going on involves
understanding how the compiler is treating internal the expression
v ? A : B
Certainly, it is not an integrable constant expression and it is an
lvalue. Wihch means the compiler is internally taking the address of
both Base::A and Base::B. Hence the link error.
| 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.
In the above, Foo::A is used in a such way that its definition isn't
needed, i.e. its address isn't taken.
I agree with you that all that is confusing. A reason why I've always
thought of that as a misfeature -- it doesn't scale easily.
-- Gaby