On Oct 1, 3:17 pm, "Francesco S. Carta" <entul...@gmail.com> wrote:
Well, I think that also Comeau gets :: base specifications wrong if
fed with something even slightly more complex, see this:
-------
struct base1{ void display(){} };
struct base2{ void display(){} };
struct der1 : base1, base2 {};
struct der2 : base1, base2 {};
struct client : der1, der2 {};
int main() {
/*
tested with
- gcc 3.4.5
- Comeau Online
both choke on last three statements
*/
client cl;
der1* p_der1 = &cl;
base1* p_base1 = p_der1;
/* compiles, OK */
p_base1->display();
/* compile error: ambiguous (OK) */
cl.display();
/* compile error: ambiguous (OK) */
cl.der1::display();
/* compile error: ambiguous (BUG???) */
cl.der1::base1::display();
}
-------
Comeau C/C++ 4.3.10.1 (Oct 6 2008 11:28:09) for
ONLINE_EVALUATION_BETA2
Copyright 1988-2008 Comeau Computing. All rights reserved.
MODE:strict errors C++ C++0x_extensions
"ComeauTest.c", line 22: error: "client::display" is ambiguous
cl.display();
^
"ComeauTest.c", line 25: error: "der1::display" is ambiguous
cl.der1::display();
^
"ComeauTest.c", line 28: error: base class "base1" is ambiguous
cl.der1::base1::display();
^
3 errors detected in the compilation of "ComeauTest.c".
In strict mode, with -tused, Compile failed
Hit the Back Button to review your code and compile options.
Compiled with C++0x extensions enabled.
-------
As far as I understand it, "cl.der1::base1::display();" should
compile, am I correct?
Odd.
gcc version 4.1.2 20070626 (Red Hat 4.1.2-14)
just choked on that too.
foo.cpp: In function ?int main()?:
foo.cpp:22: error: request for member ?display? is ambiguous
foo.cpp:2: error: candidates are: void base2::display()
foo.cpp:1: error: void base1::display()
foo.cpp:2: error: void base2::display()
foo.cpp:1: error: void base1::display()
foo.cpp:25: error: request for member ?display? is ambiguous
foo.cpp:2: error: candidates are: void base2::display()
foo.cpp:1: error: void base1::display()
foo.cpp:28: error: ?base1? is an ambiguous base of ?client?
I am also confused as I agree with your assessment Francesco. Line 28
should not be ambiguous, at least as I understand the language rules.
I'm leaning towards my understanding is flawed. Let me go see what the
standard says...
The qualifications do not constitute a hint about which 'this' pointer to pass.
to look up the 'display' name. As far as the compiler is concerned the whole
qualification chain 'der1::base1' is equivalent to writing just 'base1::'.