Bug 49105 - [C++0x][SFINAE] ICE during list-initialization of rvalue-references to const
Summary: [C++0x][SFINAE] ICE during list-initialization of rvalue-references to const
Status: RESOLVED FIXED
Alias: None
Product: gcc
Classification: Unclassified
Component: c++ (show other bugs)
Version: 4.7.0
: P3 normal
Target Milestone: 4.6.1
Assignee: Jason Merrill
URL:
Keywords:
: 44920 (view as bug list)
Depends on:
Blocks:
 
Reported: 2011-05-21 23:02 UTC by Daniel Krügler
Modified: 2011-05-29 00:45 UTC (History)
3 users (show)

See Also:
Host:
Target:
Build:
Known to work:
Known to fail:
Last reconfirmed: 2011-05-23 17:38:40


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Daniel Krügler 2011-05-21 23:02:17 UTC
gcc 4.7.0 20110514 (experimental) in C++0x mode produces an internal compiler error when compiling this code at the line marked with #:

//----
template<class T, class = decltype(T{})>
char f(int);

template<class T>
auto f(...) -> char(&)[2];

static_assert(sizeof(f<const int&&>(0)) == 1, "Error"); // #
//----

"internal compiler error: in cp_build_c_cast, at cp/typeck.c:6442|"

The code should be accepted.

Further tests provided evidence that we need an value-initialization of an rvalue reference to const T to reproduce the ICE, even though the sole initialization written as 

const int&& rri{};

does not cause the same kind of problem. This is odd, because the functional cast T{} has exactly the same semantics as the corresponding direct-list-initialization.

Additionally, the same error occurs, when the list has one element, e.g. the expression T{0} results in the same kind of error.
Comment 1 Jason Merrill 2011-05-23 22:56:00 UTC
Author: jason
Date: Mon May 23 22:55:56 2011
New Revision: 174092

URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=174092
Log:
	PR c++/49105
	* typeck.c (build_const_cast_1): Handle rvalue references.

Added:
    trunk/gcc/testsuite/g++.dg/cpp0x/rv-cast2.C
Modified:
    trunk/gcc/cp/ChangeLog
    trunk/gcc/cp/typeck.c
    trunk/gcc/testsuite/ChangeLog
Comment 2 Jason Merrill 2011-05-23 22:56:08 UTC
Author: jason
Date: Mon May 23 22:56:04 2011
New Revision: 174093

URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=174093
Log:
	PR c++/49105
	* typeck.c (cp_build_c_cast): Don't strip cv-quals when
	converting to reference.
	(build_static_cast_1): Update for glvalues.

Added:
    trunk/gcc/testsuite/g++.dg/cpp0x/sfinae25.C
Modified:
    trunk/gcc/cp/ChangeLog
    trunk/gcc/cp/typeck.c
    trunk/gcc/testsuite/ChangeLog
Comment 3 Jason Merrill 2011-05-25 01:08:42 UTC
Author: jason
Date: Wed May 25 01:08:38 2011
New Revision: 174162

URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=174162
Log:
	PR c++/49105
	* typeck.c (build_const_cast_1): Handle rvalue references.

Added:
    branches/gcc-4_6-branch/gcc/testsuite/g++.dg/cpp0x/rv-cast2.C
Modified:
    branches/gcc-4_6-branch/gcc/cp/ChangeLog
    branches/gcc-4_6-branch/gcc/cp/typeck.c
    branches/gcc-4_6-branch/gcc/testsuite/ChangeLog
Comment 4 Jason Merrill 2011-05-25 01:13:46 UTC
Fixed for 4.6.1.
Comment 5 Jason Merrill 2011-05-29 00:45:29 UTC
*** Bug 44920 has been marked as a duplicate of this bug. ***