Bug 63885 - [5 Regression] ICE in static assert of constexpr forwarding xvalue container member rvalue reference
Summary: [5 Regression] ICE in static assert of constexpr forwarding xvalue container ...
Status: RESOLVED FIXED
Alias: None
Product: gcc
Classification: Unclassified
Component: c++ (show other bugs)
Version: 5.0
: P3 normal
Target Milestone: 5.0
Assignee: Jason Merrill
URL:
Keywords:
Depends on:
Blocks: constexpr
  Show dependency treegraph
 
Reported: 2014-11-15 08:48 UTC by listcrawler
Modified: 2014-11-20 17:17 UTC (History)
1 user (show)

See Also:
Host:
Target:
Build:
Known to work:
Known to fail:
Last reconfirmed: 2014-11-18 00:00:00


Attachments
preprocessed source file (8.89 KB, text/plain)
2014-11-15 08:48 UTC, listcrawler
Details

Note You need to log in before you can comment on or make changes to this bug.
Description listcrawler 2014-11-15 08:48:02 UTC
Created attachment 33983 [details]
preprocessed source file

Internal compiler error in static assert of constexpr forwarding xvalue container member rvalue reference. 

g++ 4.8 and 4.9 passes, but trunk built from r217559 on ubuntu 14.04 fails compilation with

$ g++-trunk -std=c++11 -Wall -Wextra constexpr_static_assert.ii
constexpr_static_assert.cpp:50:39:   in constexpr expansion of ‘get<0, S<int&&> >((* & S<int&&>((* &1))))’
constexpr_static_assert.cpp:35:35:   in constexpr expansion of ‘__get<0, T>::value<S<int&&>&&>((* & std::forward<S<int&&> >((* & arg))))’
constexpr_static_assert.cpp:50:44: internal compiler error: in verify_ctor_sanity, at cp/constexpr.c:1779
 static_assert (get <0> (S <int &&> (1)) == 1, ""); // g++ 4.9 passes, g++ trunk r217559 fails

...

///////////////////////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////////////////
//
// source
//

#include <utility>

using namespace std;

///////////////////////////////////////////////////////////////////////////////

template <typename C> struct member_forward
{
    typedef typename remove_reference <C>::type::type T;
    typedef typename conditional
    <
        is_lvalue_reference <C &&>::value && not is_reference <T>::value,
        typename add_lvalue_reference <T>::type,
        T
    >::type type;
};

template <typename C> using member_forward_t = typename member_forward <C>::type;

///////////////////////////////////////////////////////////////////////////////

template <int  , typename  > struct __get;
template <       typename T> struct __get <0, T> 
{ 
    constexpr static auto value (T arg) 
     -> decltype ((forward <member_forward_t <T>> (arg.t))) 
    {  
        return     forward <member_forward_t <T>> (arg.t); 
    } 
};

template <int N, typename T> constexpr auto get (T && arg)
 -> decltype (__get <N, T &&>::value (forward <T> (arg)))
{
    return    __get <N, T &&>::value (forward <T> (arg));
}

///////////////////////////////////////////////////////////////////////////////

template <typename T> struct S
{
    typedef T type;
    T t;

    template <typename U> constexpr S (U && u) : t (forward <U> (u)) {} 
};

///////////////////////////////////////////////////////////////////////////////

static_assert (get <0> (S <int &&> (1)) == 1, ""); // g++ 4.9 passes, g++ trunk r217559 fails

int main () {}

///////////////////////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////////////////
Comment 1 Jason Merrill 2014-11-19 22:06:58 UTC
Author: jason
Date: Wed Nov 19 22:06:26 2014
New Revision: 217815

URL: https://gcc.gnu.org/viewcvs?rev=217815&root=gcc&view=rev
Log:
	PR c++/63885
	* constexpr.c (cxx_eval_constant_expression) [PARM_DECL]: Don't
	complain yet about a reference.
	[TARGET_EXPR]: Handle TARGET_EXPR with addr == true.
	[ADDR_EXPR]: Make sure we don't take the address of a CONSTRUCTOR.
	(cxx_bind_parameters_in_call): In the new scheme addr is always false.
	* typeck.c (build_address): Don't take the address of a CONSTRUCTOR.

Added:
    trunk/gcc/testsuite/g++.dg/cpp0x/constexpr-ref8.C
Modified:
    trunk/gcc/cp/ChangeLog
    trunk/gcc/cp/constexpr.c
    trunk/gcc/cp/typeck.c
Comment 2 Jason Merrill 2014-11-20 03:37:05 UTC
Fixed.
Comment 3 listcrawler 2014-11-20 17:17:51 UTC
I tested the latest revision this morning and all my tests passed. Thanks!