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

            Bug ID: 97610
           Summary: [10/11] template argument deduction fails for function
                    with defaulted lambda as non-type-template parameter
           Product: gcc
           Version: 11.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c++
          Assignee: unassigned at gcc dot gnu.org
          Reporter: lutztonineubert at gmail dot com
  Target Milestone: ---

The following code (with C++20 enabled):

template<auto = []{}>
constexpr auto nested() {
        return 1;
}

template<typename T>
constexpr void test() {
        static_assert(nested());
}

------------------

Fails with:

<source>: In function 'constexpr void test()':
<source>:8:30: error: no matching function for call to 'nested()'
    8 |         static_assert(nested());
      |                              ^
<source>:2:16: note: candidate: 'template<auto <anonymous> > constexpr auto
nested()'
    2 | constexpr auto nested() {
      |                ^~~~~~
<source>:2:16: note:   template argument deduction/substitution failed:

------------------

* same error happens if nested() has template<typename = decltype([]{})> as
this template parameters
* if the template non-type parameter of nested() is defaulted to 1, it compiles
* if test() is not a template function, it compiles
* if static_assert(nested<[]{}>()); is used, it compiles

Reply via email to