Bug 57901

Summary: [4.8/4.9 Regression] Cannot call-by-value such that class has non-trivial (constexpr) move constructor
Product: gcc Reporter: MURAKAMI Genya <bolero.murakami>
Component: c++Assignee: Jason Merrill <jason>
Severity: normal CC: daniel.kruegler, jason
Priority: P3    
Version: 4.8.1   
Target Milestone: 4.8.2   
Host: Target:
Build: Known to work: 4.7.3
Known to fail: 4.8.0, 4.8.1, 4.9.0 Last reconfirmed: 2013-07-22 00:00:00
Bug Depends on:    
Bug Blocks: 55004    

Description MURAKAMI Genya 2013-07-15 18:17:04 UTC
struct Z {
    Z()         = default;
    Z(Z const&) = default;
    constexpr Z(Z&&) {} /* non-trivial (constexpr) move ctor */

template<typename T>
constexpr int fn0(T v) { return 0; }
template<typename T>
constexpr int fn (T v) { return fn0(v); }

constexpr auto t0 = fn0(Z()); // OK!
constexpr auto t  = fn (Z()); // error! (GCC 4.8.1, -std=c++11)

Error message:
in constexpr expansion of ‘fn<Z>(Z())’
error: ‘v’ is not a constant expression
   constexpr auto t = fn(Z());

Class Z is literal type.
However, compilation error when it is call-by-value(more than once).

I tested this code in gcc-4.7.3, is passed.
The problem is reproduced in gcc-4.8.0, gcc-4.8.1
Comment 1 Paolo Carlini 2013-07-22 10:00:17 UTC
We may have a Dup of this.
Comment 2 Jason Merrill 2013-07-30 16:59:42 UTC
Fixed for 4.8.2/4.9.0.