https://gcc.gnu.org/bugzilla/show_bug.cgi?id=71136
Bug ID: 71136 Summary: [concepts] Spurious 'converting overloaded function is ambiguous' error. Product: gcc Version: unknown Status: UNCONFIRMED Severity: normal Priority: P3 Component: c++ Assignee: unassigned at gcc dot gnu.org Reporter: tom at honermann dot net CC: andrew.n.sutton at gmail dot com, asutton at gcc dot gnu.org Target Milestone: --- I believe the following test case is well-formed, but it is rejected by gcc r236238. $ cat t.cpp template<typename, typename> struct is_same {}; template<typename T> struct is_same<T, T> { using type = T; }; // Concept imposes a same-type-as-int constraint. template<typename T> concept bool C = requires { typename is_same<T, int>::type; }; template<typename U> constexpr int f() { return 0; } // #1, unconstrained overload. template<C U> constexpr int f() { return 1; } // #2, constrained overload. // Obtaining a function pointer to #1 is ok: constexpr auto x0 = f<char>; // Ok, overload selects #1 static_assert(x0() == 0); // Ok. // Invoking #2 is ok: constexpr auto x1 = f<int>(); // Ok, overload selects #2 static_assert(x1 == 1); // Ok. // Obtaining a function pointer to #2 fails: constexpr auto x2 = f<int>; // spurious error: 'converting overloaded // function is ambiguous'; should select #2. static_assert(x2() == 1); $ svn info Path: . Working Copy Root Path: /home/tom/src/gcc-trunk URL: svn://gcc.gnu.org/svn/gcc/trunk Relative URL: ^/trunk Repository Root: svn://gcc.gnu.org/svn/gcc Repository UUID: 138bc75d-0d04-0410-961f-82ee72b054a4 Revision: 236239 Node Kind: directory Schedule: normal Last Changed Author: uros Last Changed Rev: 236238 Last Changed Date: 2016-05-14 05:07:13 -0400 (Sat, 14 May 2016) $ g++ --version g++ (GCC) 7.0.0 20160514 (experimental) ... $ g++ -c -std=c++1z -fconcepts t.cpp t.cpp:24:21: error: converting overloaded function ‘f’ to type ‘int (* const)()’ is ambiguous constexpr auto x2 = f<int>; // spurious error: 'converting overloaded ^~~~~~ t.cpp:11:15: note: candidates are: constexpr int f() [with U = int] constexpr int f() { return 0; } // #1, unconstrained overload. ^ t.cpp:13:15: note: constexpr int f() [with U = int] constexpr int f() { return 1; } // #2, constrained overload. ^ t.cpp:26:1: error: non-constant condition for static assertion static_assert(x2() == 1); ^~~~~~~~~~~~~