Bug 44521 - unhelpful candidates for ambiguous lookup
Summary: unhelpful candidates for ambiguous lookup
Status: NEW
Alias: None
Product: gcc
Classification: Unclassified
Component: c++ (show other bugs)
Version: unknown
: P3 enhancement
Target Milestone: ---
Assignee: Not yet assigned to anyone
URL:
Keywords: diagnostic
Depends on:
Blocks:
 
Reported: 2010-06-13 13:40 UTC by Manuel López-Ibáñez
Modified: 2021-08-10 01:34 UTC (History)
3 users (show)

See Also:
Host:
Target:
Build:
Known to work:
Known to fail:
Last reconfirmed: 2021-08-09 00:00:00


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Manuel López-Ibáñez 2010-06-13 13:40:24 UTC
Testcase:

struct B1 { void f(); };
struct B2 { void f(double); };

struct I1 : B1 { };
struct I2 : B1 { };

struct D: I1, I2, B2 {
  void g() {
    f();
  }
};


gcc-4.6:

clang-8.C:9:5: error: reference to ‘f’ is ambiguous
clang-8.C:2:18: error: candidates are: void B2::f(double)
clang-8.C:1:18: error:                 void B1::f()
clang-8.C:1:18: error:                 void B1::f()

B1 is printed twice and there is no clear info about the hierarchy.

clang:

t.cc:10:5: error: non-static member 'f' found in multiple base-class subobjects of type 'B1':
    struct D -> struct I1 -> struct B1
    struct D -> struct I2 -> struct B1
    f(); 
    ^
t.cc:1:18: note: member found by ambiguous name lookup
struct B1 { void f(); };
                 ^
Comment 1 Manuel López-Ibáñez 2014-08-20 23:50:07 UTC
Jason, do we want this?

Following Clang or in some other way?
Comment 2 Jason Merrill 2014-08-21 02:11:47 UTC
(In reply to Manuel López-Ibáñez from comment #1)
> Jason, do we want this?
> 
> Following Clang or in some other way?

Yes, the Clang diagnostic is better.

There are two issues with the G++ diagnostic:

1) It talks about f(double), which is not viable.
2) It doesn't distinguish between two occurrences of the same function reached through different base paths.