Bug 20576 - poor diagnostic
Summary: poor diagnostic
Status: RESOLVED DUPLICATE of bug 16057
Alias: None
Product: gcc
Classification: Unclassified
Component: c++ (show other bugs)
Version: 3.4.0
: P2 normal
Target Milestone: ---
Assignee: Not yet assigned to anyone
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2005-03-21 12:25 UTC by Ivan Godard
Modified: 2005-07-23 22:49 UTC (History)
1 user (show)

See Also:
Host:
Target:
Build:
Known to work:
Known to fail:
Last reconfirmed:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Ivan Godard 2005-03-21 12:25:32 UTC
In:
struct bottom {};
template<typename v, typename next>
struct node: public next { v val; };
enum a {b, c}; enum x{y, z};
struct foo : public node<a,
                    node<x,
                        bottom> > {};
template<typename T, typename U>
void bar(node<T, U>&) {}
int main() { foo f; bar(f); return 0; }


you get:
~/ootbc/members/src$ g++ foo.cc
foo.cc: In function `int main()':
foo.cc:10: error: no matching function for call to `bar(foo&)'

Actually, there is a matching function, but the call is ambiguous because there 
are two matching base classes. The diagnostic should say so and identify the 
matching bases. This is reported correctly by other ambiguous calls where two 
different functions are matches to the argument set. In this case one function 
has two different matches, but the user's need in the diagnostic is the same: 
show what the compiler found.

Ivan
Comment 1 Ivan Godard 2005-03-21 12:39:22 UTC
The same case but using derivation from classes rather than templates:

struct foo {};
struct bar : public foo {};
struct baz : public bar {};
struct baf : public foo, public baz {};
void F(foo&) {}
int main() { baf b; F(b); return 0; }


gives a much better diagnostic:

~/ootbc/members/src$ g++ foo.cc
foo.cc:4: warning: direct base `foo' inaccessible in `baf' due to ambiguity
foo.cc: In function `int main()':
foo.cc:6: error: `foo' is an ambiguous base of `baf'
Comment 2 Wolfgang Bangerth 2005-03-21 22:05:12 UTC
I'm absolutely positive this is a duplicate of a fair number of other PRs, 
though I can't find one with a 20 second search. PR 13979 may be one, but 
doesn't have a really short testcase so I can't tell for sure. 
 
W. 
Comment 3 Andrew Pinski 2005-06-20 03:01:34 UTC

*** This bug has been marked as a duplicate of 16057 ***