This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
[Bug c++/80268] New: [concepts] list of candidates for ambiguous call includes unconstrained function
- From: "redi at gcc dot gnu.org" <gcc-bugzilla at gcc dot gnu dot org>
- To: gcc-bugs at gcc dot gnu dot org
- Date: Fri, 31 Mar 2017 00:46:47 +0000
- Subject: [Bug c++/80268] New: [concepts] list of candidates for ambiguous call includes unconstrained function
- Auto-submitted: auto-generated
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=80268
Bug ID: 80268
Summary: [concepts] list of candidates for ambiguous call
includes unconstrained function
Product: gcc
Version: 7.0.1
Status: UNCONFIRMED
Keywords: diagnostic
Severity: normal
Priority: P3
Component: c++
Assignee: unassigned at gcc dot gnu.org
Reporter: redi at gcc dot gnu.org
Target Milestone: ---
This rightly fails to compile with -fconcepts:
template<typename T>
inline constexpr bool is_int_sized = sizeof(T) == sizeof(int);
template<typename T>
inline constexpr bool is_signed = (T(-1) < T(0));
template<typename T> void func(T) { }
template<typename T> void func(T) requires is_int_sized<T> { }
template<typename T> void func(T) requires is_signed<T> { }
int main()
{
func(1);
}
ambig.cc: In function ‘int main()’:
ambig.cc:15:9: error: call of overloaded ‘func(int)’ is ambiguous
func(1);
^
ambig.cc:7:27: note: candidate: void func(T) [with T = int]
template<typename T> void func(T) { }
^~~~
ambig.cc:9:27: note: candidate: void func(T) requires is_int_sized<T> [with T
= int]
template<typename T> void func(T) requires is_int_sized<T> { }
^~~~
ambig.cc:11:27: note: candidate: void func(T) requires is_signed<T> [with T =
int]
template<typename T> void func(T) requires is_signed<T> { }
^~~~
I think showing the first candidate in the error isn't very useful. The
ambiguity is between the 2nd and 3rd overloads, because neither is more
constrained than the other. But both are more constrained than the first, and
it would never be chosen as the best match if only one of the others was a
candidate (rather than both).
I know we'd show all candidates in an unconstrained case, but I wonder if we
should do things differently for constrained functions.