Bug 57901 - [4.8/4.9 Regression] Cannot call-by-value such that class has non-trivial (constexpr) move constructor
Summary: [4.8/4.9 Regression] Cannot call-by-value such that class has non-trivial (co...
Status: RESOLVED FIXED
Alias: None
Product: gcc
Classification: Unclassified
Component: c++ (show other bugs)
Version: 4.8.1
: P3 normal
Target Milestone: 4.8.2
Assignee: Jason Merrill
URL:
Keywords:
Depends on:
Blocks: constexpr
  Show dependency treegraph
 
Reported: 2013-07-15 18:17 UTC by MURAKAMI Genya
Modified: 2013-07-30 16:59 UTC (History)
2 users (show)

See Also:
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


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description MURAKAMI Genya 2013-07-15 18:17:04 UTC
Code:
//--------
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.