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

--- Comment #4 from TC <rs2740 at gmail dot com> ---
Although this still breaks on trunk GCC on Wandbox:

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; }
                         ^

I guess PR64969's fix only handled functions returning 'auto', and not
something more complicated.

Reply via email to