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

            Bug ID: 101463
           Summary: Using a constexpr variable template specialization as
                    default argument for non-type template parameter of
                    reference type leads gcc to reject function call
           Product: gcc
           Version: 11.1.1
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c++
          Assignee: unassigned at gcc dot gnu.org
          Reporter: michael.kenzel at gmail dot com
  Target Milestone: ---

The following code will reproduce the issue:

    extern const int a;

    template <typename T>
    constexpr const int& blub = a;

    template <typename T, const int& b = blub<T>>
    void f() {}

    int main()
    {
        f<void>();              // error: no matching function for call to
'f<void>()'
        f<void, blub<void>>();  // ok
    }

Note: gcc will accept the function call when the exact same template argument
is explicitly specified instead.

godbolt link: https://godbolt.org/z/jd3EGWEfo

Reply via email to