[Bug c++/90546] [9/10 Regression] Incorrect template argument deduction for conversion functions

2020-02-26 Thread jason at gcc dot gnu.org
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=90546
Bug 90546 depends on bug 86521, which changed state.

Bug 86521 Summary: [8 Regression] GCC 8 selects incorrect overload of 
ref-qualified conversion operator template
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=86521

   What|Removed |Added

 Status|ASSIGNED|RESOLVED
 Resolution|--- |FIXED

[Bug c++/90546] [9/10 Regression] Incorrect template argument deduction for conversion functions

2020-02-25 Thread cvs-commit at gcc dot gnu.org
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=90546

--- Comment #11 from CVS Commits  ---
The releases/gcc-8 branch has been updated by Jason Merrill
:

https://gcc.gnu.org/g:c93117eea148326a718ae1e413bc85f4fa257d8f

commit r8-10079-gc93117eea148326a718ae1e413bc85f4fa257d8f
Author: Jason Merrill 
Date:   Wed Feb 26 00:33:52 2020 -0500

c++: Allow template rvalue-ref conv to bind to lvalue ref.

When I implemented the [over.match.ref] rule that a reference conversion
function needs to match l/rvalue of the target reference type it changed
our
handling of this testcase.  It seems to me that our current behavior is
what
the standard says, but it doesn't seem desirable, and all the other
compilers have our old behavior.  So let's limit the change to
non-templates
until there's some clarification from the committee.

gcc/cp/ChangeLog
2020-02-26  Jason Merrill  

PR c++/90546
* call.c (build_user_type_conversion_1): Allow a template conversion
returning an rvalue reference to bind directly to an lvalue.

[Bug c++/90546] [9/10 Regression] Incorrect template argument deduction for conversion functions

2020-02-14 Thread jason at gcc dot gnu.org
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=90546

Jason Merrill  changed:

   What|Removed |Added

 CC||gufideg at gmail dot com

--- Comment #10 from Jason Merrill  ---
*** Bug 91051 has been marked as a duplicate of this bug. ***

[Bug c++/90546] [9/10 Regression] Incorrect template argument deduction for conversion functions

2020-01-28 Thread jason at gcc dot gnu.org
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=90546

Jason Merrill  changed:

   What|Removed |Added

 Status|ASSIGNED|RESOLVED
 Resolution|--- |FIXED

--- Comment #9 from Jason Merrill  ---
Fixed for 9.3/10.

[Bug c++/90546] [9/10 Regression] Incorrect template argument deduction for conversion functions

2020-01-28 Thread cvs-commit at gcc dot gnu.org
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=90546

--- Comment #8 from CVS Commits  ---
The releases/gcc-9 branch has been updated by Jason Merrill
:

https://gcc.gnu.org/g:1c7061c7c352e086b64a60b91e5204f9757bfa97

commit r9-8186-g1c7061c7c352e086b64a60b91e5204f9757bfa97
Author: Jason Merrill 
Date:   Tue Jan 28 12:26:10 2020 -0500

c++: Allow template rvalue-ref conv to bind to lvalue ref.

When I implemented the [over.match.ref] rule that a reference conversion
function needs to match l/rvalue of the target reference type it changed
our
handling of this testcase.  It seems to me that our current behavior is
what
the standard says, but it doesn't seem desirable, and all the other
compilers have our old behavior.  So let's limit the change to
non-templates
until there's some clarification from the committee.

PR c++/90546
* call.c (build_user_type_conversion_1): Allow a template conversion
returning an rvalue reference to bind directly to an lvalue.

[Bug c++/90546] [9/10 Regression] Incorrect template argument deduction for conversion functions

2020-01-28 Thread cvs-commit at gcc dot gnu.org
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=90546

--- Comment #7 from CVS Commits  ---
The master branch has been updated by Jason Merrill :

https://gcc.gnu.org/g:14e320dbc10cc796fd7ca0b6c44e0c9ac0901da9

commit r10-6300-g14e320dbc10cc796fd7ca0b6c44e0c9ac0901da9
Author: Jason Merrill 
Date:   Tue Jan 28 12:26:10 2020 -0500

c++: Allow template rvalue-ref conv to bind to lvalue ref.

When I implemented the [over.match.ref] rule that a reference conversion
function needs to match l/rvalue of the target reference type it changed
our
handling of this testcase.  It seems to me that our current behavior is
what
the standard says, but it doesn't seem desirable, and all the other
compilers have our old behavior.  So let's limit the change to
non-templates
until there's some clarification from the committee.

PR c++/90546
* call.c (build_user_type_conversion_1): Allow a template conversion
returning an rvalue reference to bind directly to an lvalue.

[Bug c++/90546] [9/10 Regression] Incorrect template argument deduction for conversion functions

2020-01-28 Thread jason at gcc dot gnu.org
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=90546

--- Comment #6 from Jason Merrill  ---
This changed from the fix for PR 86521.

As you say, deduction is first done with P = T&&, A = const Foo&, and deduces
'const Foo' for T.  This produces operator const Foo&&.  But according to
[over.match.ref], we don't consider a conversion function yielding an rvalue
reference (const Foo&&) for direct reference binding to an lvalue reference
(const Foo&), so we fall back on creating a temporary Foo and binding the
reference to that.

On the other hand, the rules in [dcl.init.ref] are more forgiving; this case
seems to hit the bullet

Otherwise, if the initializer expression...has a class type (i.e., T2 is a
class type), where T1 is not reference-related to T2, and can be converted to
an rvalue or function lvalue of type “cv3 T3”, where “cv1 T1” is
reference-compatible
with “cv3 T3” (see 12.4.1.6), then the value of the initializer expression in
the first case and the result of the conversion in the second case is called
the converted initializer In any case, the reference is bound to the
resulting glvalue (or to an appropriate base class subobject).

So if we ignored the [over.match.ref] rule we would happily bind directly to
the xvalue from operator const Foo&&.  The standard is definitely unclear here,
but no other implementation agrees with us on this testcase.  I suppose for now
I'll limit the [over.match.ref] limitation to only apply to non-template
conversions.

[Bug c++/90546] [9/10 Regression] Incorrect template argument deduction for conversion functions

2020-01-28 Thread jason at gcc dot gnu.org
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=90546

Jason Merrill  changed:

   What|Removed |Added

 Status|NEW |ASSIGNED
 CC||jason at gcc dot gnu.org
 Depends on||86521
   Assignee|unassigned at gcc dot gnu.org  |jason at gcc dot gnu.org


Referenced Bugs:

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=86521
[Bug 86521] [8 Regression] GCC 8 selects incorrect overload of ref-qualified
conversion operator template

[Bug c++/90546] [9/10 Regression] Incorrect template argument deduction for conversion functions

2020-01-17 Thread rguenth at gcc dot gnu.org
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=90546

Richard Biener  changed:

   What|Removed |Added

   Priority|P3  |P2

[Bug c++/90546] [9/10 Regression] Incorrect template argument deduction for conversion functions

2019-08-12 Thread jakub at gcc dot gnu.org
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=90546

Jakub Jelinek  changed:

   What|Removed |Added

   Target Milestone|9.2 |9.3

--- Comment #5 from Jakub Jelinek  ---
GCC 9.2 has been released.

[Bug c++/90546] [9/10 Regression] Incorrect template argument deduction for conversion functions

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

--- Comment #4 from Nick Krempel  ---
Here's one way to turn it into a test case which fails to compile:

struct Foo {};
void test(const Foo&) {}
Foo f;
struct Bar {
  template  operator T&&() = delete;
};
template<> Bar::operator const Foo&&() {
return static_cast(f);
}
int main() {
  test(Bar{});
}

[Bug c++/90546] [9/10 Regression] Incorrect template argument deduction for conversion functions

2019-05-21 Thread rguenth at gcc dot gnu.org
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=90546

Richard Biener  changed:

   What|Removed |Added

   Keywords||wrong-code
 Status|UNCONFIRMED |NEW
   Last reconfirmed||2019-05-21
  Known to work||8.3.0
   Target Milestone|--- |9.2
Summary|[9.1 regression] Incorrect  |[9/10 Regression] Incorrect
   |template argument deduction |template argument deduction
   |for conversion functions|for conversion functions
 Ever confirmed|0   |1

--- Comment #3 from Richard Biener  ---
Confirmed change in behavior - different operators are instantiated.  As you
say a DR might be in order?

I guess one could craft a testcase that either is rejected after the behavioral
change or at least fails to link?