This is the mail archive of the gcc-bugs@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[Bug c++/69448] New: Abbreviated function templates with deduced return type still broken


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

            Bug ID: 69448
           Summary: Abbreviated function templates with deduced return
                    type still broken
           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: ---

PR64969 fixed cases where an abbreviated function template returns 'auto' or
'decltype(auto)' (or have a trailing return type), but returning `auto*` and
`auto&` etc. is still broken:

long x;
auto& f(auto) { return x; }
auto* g(auto) { return &x; }
auto r = f(1);
auto p = g(1);

prog.cc: In instantiation of 'auto& f(auto:1) [with auto:1 = int]':
prog.cc:4:13:   required from here
prog.cc:2:24: error: invalid initialization of non-const reference of type
'int&' from an rvalue of type 'int'
 auto& f(auto) { return x; }
                        ^

prog.cc: In instantiation of 'auto* g(auto:2) [with auto:2 = int]':
prog.cc:5:13:   required from here
prog.cc:3:25: error: cannot convert 'long int*' to 'int*' in return
 auto* g(auto) { return &x; }
                         ^

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]