https://gcc.gnu.org/bugzilla/show_bug.cgi?id=71136

Jonathan Wakely <redi at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
           Keywords|                            |rejects-valid
             Status|UNCONFIRMED                 |NEW
   Last reconfirmed|                            |2019-10-14
     Ever confirmed|0                           |1

--- Comment #1 from Jonathan Wakely <redi at gcc dot gnu.org> ---
This still fails on trunk when updated for C++2a syntax, using -std=gnu++2a:

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 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);


71136.cc:24:21: error: converting overloaded function 'f' to type 'int (*
const)()' is ambiguous
   24 | constexpr auto x2 = f<int>;     // spurious error: 'converting
overloaded
      |                     ^~~~~~
71136.cc:11:15: note: candidates are: 'constexpr int f() [with U = int]'
   11 | constexpr int f() { return 0; } // #1, unconstrained overload.
      |               ^
71136.cc:13:15: note:                 'constexpr int f() [with U = int]'
   13 | constexpr int f() { return 1; } // #2, constrained overload.
      |               ^
71136.cc:26:20: error: non-constant condition for static assertion
   26 | static_assert(x2() == 1);
      |               ~~~~~^~~~

Reply via email to