Bug 50442 - [4.6 regression] Constructing T from implicit conversion to T& ambiguous in C++0x mode, not C++98
Summary: [4.6 regression] Constructing T from implicit conversion to T& ambiguous in C...
Status: RESOLVED FIXED
Alias: None
Product: gcc
Classification: Unclassified
Component: c++ (show other bugs)
Version: 4.6.2
: P3 normal
Target Milestone: 4.6.2
Assignee: Jason Merrill
URL:
Keywords: rejects-valid
Depends on:
Blocks:
 
Reported: 2011-09-17 04:49 UTC by Zack Weinberg
Modified: 2011-09-20 19:25 UTC (History)
3 users (show)

See Also:
Host:
Target:
Build:
Known to work:
Known to fail:
Last reconfirmed: 2011-09-17 00:00:00


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Zack Weinberg 2011-09-17 04:49:00 UTC
This test case ...

    template <typename T> struct MoveRef { operator T& () {} };
    template <typename T> MoveRef <T> Move(T&) {}
    struct Thing {};
    Thing foo(const Thing* p) { return Thing(Move(*p)); }

... generates these diagnostics from g++ 4.6.1 in c++0x/gnu++0x mode, but not in c++98/gnu++98 mode:

t.cc: In function ‘Thing foo(const Thing*)’:
t.cc:4:50: error: call of overloaded ‘Thing(MoveRef<const Thing>)’ is ambiguous
t.cc:4:50: note: candidates are:
t.cc:3:8: note: constexpr Thing::Thing(const Thing&)
t.cc:3:8: note: constexpr Thing::Thing(Thing&&)

This is a regression from g++ 4.5.x and earlier.
Comment 1 Mike Hommey 2011-09-17 06:21:28 UTC
More specifically, r178746 from SVN gcc-4_6-branch is affected, while r178501 from the same branch is not.
Comment 2 Jonathan Wakely 2011-09-17 09:45:11 UTC
maybe the fix for PR 49267 then, Jason?
Comment 3 Jonathan Wakely 2011-09-17 09:48:55 UTC
yep, confirmed that r178552 changed the behaviour
Comment 4 Jason Merrill 2011-09-17 22:35:15 UTC
Author: jason
Date: Sat Sep 17 22:35:10 2011
New Revision: 178932

URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=178932
Log:
	PR c++/50442
	Revert:
	PR c++/49267
	* call.c (compare_ics): rvaluedness_matches_p can differ
	based on the source type, not just target.

Removed:
    branches/gcc-4_6-branch/gcc/testsuite/g++.dg/cpp0x/rv-conv1.C
Modified:
    branches/gcc-4_6-branch/gcc/cp/ChangeLog
    branches/gcc-4_6-branch/gcc/cp/call.c
    branches/gcc-4_6-branch/gcc/testsuite/ChangeLog
Comment 5 Jason Merrill 2011-09-17 22:35:48 UTC
Fixed by reverting the earlier patch.
Comment 6 Jason Merrill 2011-09-20 19:25:36 UTC
Author: jason
Date: Tue Sep 20 19:25:32 2011
New Revision: 179015

URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=179015
Log:
	PR c++/50442
	* g++.dg/overload/ref-conv1.C: New.

Added:
    trunk/gcc/testsuite/g++.dg/overload/ref-conv1.C
Modified:
    trunk/gcc/testsuite/ChangeLog