[Bug c++/69139] New: [4.9/5/6 Regression] deduction failure with trailing return type in function template argument

rs2740 at gmail dot com gcc-bugzilla@gcc.gnu.org
Mon Jan 4 23:48:00 GMT 2016


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

            Bug ID: 69139
           Summary: [4.9/5/6 Regression] deduction failure with trailing
                    return type in function template argument
           Product: gcc
           Version: 6.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c++
          Assignee: unassigned at gcc dot gnu.org
          Reporter: rs2740 at gmail dot com
  Target Milestone: ---

Test case (modified from http://stackoverflow.com/q/31229359/2756719):

auto get(int) -> int { return {}; }
template <class R> int f(auto (*)(int) -> R) { return {}; }
int i = f(get);

Compiles on 4.8.2, fails on 4.9 and later:

prog.cc:3:14: error: no matching function for call to 'f(int (&)(int))'
 int i = f(get);
              ^

prog.cc:2:24: note: candidate: template<class R, class auto:1> int f(auto:1
(*)(int))
 template <class R> int f(auto (*)(int) -> R) { return {}; }
                        ^

prog.cc:2:24: note:   template argument deduction/substitution failed:
prog.cc:3:14: note:   couldn't deduce template parameter 'R'
 int i = f(get);
              ^

It seems as if the 'auto' indicating the trailing return type is being treated
as introducing another template parameter, as if in abbreviated function
templates, and then the trailing return type is just ignored.


More information about the Gcc-bugs mailing list