https://gcc.gnu.org/bugzilla/show_bug.cgi?id=90546
Bug ID: 90546 Summary: [9.1 regression] Incorrect template argument deduction for conversion functions Product: gcc Version: 9.1.1 Status: UNCONFIRMED Severity: normal Priority: P3 Component: c++ Assignee: unassigned at gcc dot gnu.org Reporter: ndkrempel at gmail dot com Target Milestone: --- The following code deduces T = Foo using gcc 9.1, whereas gcc 8.3 (and clang 7 up) deduced T = const Foo. My reading of the standard (see below) is that T = const Foo is correct. struct Foo {}; void test(const Foo&); struct Bar { template <typename T> operator T&&(); }; int main() { test(Bar{}); } (compiled with -std=c++2a, but same behaviour with all language versions) Relevant standards text: http://eel.is/c++draft/temp.deduct.conv My reading of this applied to the above program is: P is T&&, A is const Foo& P is a reference type -> just treat as T from here on A is not cv-qualified A is a reference type -> use const Foo for type deduction Now attempting to match T with const Foo succeeds with T = const Foo, so we don't even need to consider the four bulleted exceptional cases ("These alternatives are considered only if type deduction would otherwise fail.")