c++/10086: static const int unresolved in ? : construct
Gabriel Dos Reis
gdr@integrable-solutions.net
Sun Mar 16 10:31:00 GMT 2003
"Giovanni Bajo" <giovannibajo@libero.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
More information about the Gcc-bugs
mailing list