https://gcc.gnu.org/bugzilla/show_bug.cgi?id=101588
Bug ID: 101588
Summary: rejects valid constexpr when binding from a constexpr
function
Product: gcc
Version: 12.0
Status: UNCONFIRMED
Keywords: rejects-valid
Severity: normal
Priority: P3
Component: c++
Assignee: unassigned at gcc dot gnu.org
Reporter: pinskia at gcc dot gnu.org
Target Milestone: ---
Split out from PR 66287.
Take:
struct T { int i; };
constexpr T copy(const T& v) { return v; }
constexpr const auto& r = T{42};
constexpr const auto& c = copy(r);
int main() {}
----- CUT ----
This should be accepted by GCC but currently is rejected:
<source>:11:33: error: modification of '<temporary>' is not a constant
expression
11 | constexpr const auto& c = copy(r);
| ^