https://gcc.gnu.org/bugzilla/show_bug.cgi?id=90159
Bug ID: 90159 Summary: Poor warning for an ambiguous reference Product: gcc Version: 9.0 Status: UNCONFIRMED Severity: normal Priority: P3 Component: c++ Assignee: unassigned at gcc dot gnu.org Reporter: david.bolvansky at gmail dot com Target Milestone: --- Test case: #include <queue> #include <algorithm> using namespace std; struct sort_heap { bool operator()(const int* lhs, const int* rhs) const { return *lhs < *rhs; } }; void foo() { std::priority_queue<int*, std::vector<int*>, sort_heap> tmp; } <source>: In function 'void foo()': <source>:16:59: error: template argument 3 is invalid 16 | std::priority_queue<int*, std::vector<int*>, sort_heap> tmp; | ^ <source>:16:61: warning: unused variable 'tmp' [-Wunused-variable] 16 | std::priority_queue<int*, std::vector<int*>, sort_heap> tmp; | ^~~ GCC does not provide enough info why argument is really invalid. Clang produces more info, which explain the root problem: Clang <source>:16:50: error: reference to 'sort_heap' is ambiguous std::priority_queue<int*, std::vector<int*>, sort_heap> tmp; ^ <source>:6:8: note: candidate found by name lookup is 'sort_heap' struct sort_heap ^ /opt/compiler-explorer/gcc-8.3.0/lib/gcc/x86_64-linux-gnu/8.3.0/../../../../include/c++/8.3.0/bits/algorithmfwd.h:576:5: note: candidate found by name lookup is 'std::sort_heap' sort_heap(_RAIter, _RAIter, _Compare); ^