[Bug c++/90546] [9.1 regression] Incorrect template argument deduction for conversion functions

2019-05-20 Thread ndkrempel at gmail dot com
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=90546

--- Comment #2 from Nick Krempel  ---
However it's also worth noting that if you take the original snippet and change
the declaration of "test" to accept a const rvalue reference instead: "void
test(const Foo&&);", then gcc 9.1 (and all other gcc and clang versions tested)
agree that T = const Foo in that case. So even if the standard is ambiguous,
gcc is still somewhat inconsistent.

[Bug c++/90546] [9.1 regression] Incorrect template argument deduction for conversion functions

2019-05-20 Thread ndkrempel at gmail dot com
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=90546

--- Comment #1 from Nick Krempel  ---
My interpretation of the standard didn't take into account the reference to
http://eel.is/c++draft/over.match.ref when determining the type A.

It says that A will be "lvalue reference to cv2 T2 ... where cv1 T is
reference-compatible with cv2 T2". Here "cv1 T" is "const Foo". This seems to
allows cv2 T2 to be either "Foo" or "const Foo", hence A can be either "Foo&"
or "const Foo&".

It's not clear which is supposed to be picked for use in the template argument
deduction in that case! It seems it was expected for there to be a unique type
from the wording:

"... with the type that is required as the result of the conversion (call it A;
..."

(note "*the* type", "call *it* A").