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++/64969] New: generic functions do not work with placeholder return types


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

            Bug ID: 64969
           Summary: generic functions do not work with placeholder return
                    types
           Product: gcc
           Version: 4.9.2
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c++
          Assignee: unassigned at gcc dot gnu.org
          Reporter: rs2740 at gmail dot com

GCC 4.9 added generic functions based on the draft Concepts Lite TS N3889.
(They now called abbreviated function templates.) However, the implementation
does not work with placeholder return types (including both deduced ones and
trailing return types).

For example, all three declarations

auto f1(auto x) { return x++; }
decltype(auto) f2(auto x) { return x++; }
auto f3(auto x) -> int { return x++; }

are apparently treated as if they were equivalent to

template<class T>
T f1(T x) { return x++; }
// etc.

rather than 

template<class T>
auto f1(T x) { return x++; }
// etc.

This is easily observable with

struct X {
    int operator++(int) const { return 0; }
};

f1(X());

which does not compile, complaining that int cannot be converted to X.


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