[Bug c++/90236] New: bogus error with auto non-type template argument

mpolacek at gcc dot gnu.org gcc-bugzilla@gcc.gnu.org
Wed Apr 24 18:58:00 GMT 2019


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

            Bug ID: 90236
           Summary: bogus error with auto non-type template argument
           Product: gcc
           Version: 8.3.1
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c++
          Assignee: unassigned at gcc dot gnu.org
          Reporter: mpolacek at gcc dot gnu.org
  Target Milestone: ---

Compiling this with g++8 and -std=c++17

struct foo { };

template <const auto &> void fnc() { } 

void
test()
{
  static constexpr foo a;
  fnc<a>();
}

results in

r.cc: In function ‘void test()’:
r.cc:9:10: error: no matching function for call to ‘fnc<a>()’
   fnc<a>();
          ^
r.cc:3:30: note: candidate: ‘template<const auto& <anonymous> > void fnc()’
 template <const auto &> void fnc() { }
                              ^~~
r.cc:3:30: note:   template argument deduction/substitution failed:
r.cc:9:10: error: ‘a’ is not a valid template argument for type ‘const foo&’
because object ‘a’ does not have linkage
   fnc<a>();
          ^

This doesn't happen on trunk since r265789, so maybe we need to apply parts of
that commit to 8.


More information about the Gcc-bugs mailing list