[llvm-bugs] [Bug 43086] New: constexpr variable initialisation error after forwarding reference
via llvm-bugs
llvm-bugs at lists.llvm.org
Thu Aug 22 02:43:16 PDT 2019
https://bugs.llvm.org/show_bug.cgi?id=43086
Bug ID: 43086
Summary: constexpr variable initialisation error after
forwarding reference
Product: clang
Version: trunk
Hardware: PC
OS: Linux
Status: NEW
Severity: normal
Priority: P
Component: C++11
Assignee: unassignedclangbugs at nondot.org
Reporter: pkeir at outlook.com
CC: blitzrakete at gmail.com, dgregor at apple.com,
erik.pilkington at gmail.com, llvm-bugs at lists.llvm.org,
richard-llvm at metafoo.co.uk
Created attachment 22413
--> https://bugs.llvm.org/attachment.cgi?id=22413&action=edit
Code as described.
The C++11 code below (also attached) will fail to compile:
struct Bar {};
struct Foo { Bar t; };
template <typename T>
constexpr T jam(T &&a) { return a; }
void test()
{
Foo y;
constexpr Foo x = jam(y);
}
Changing the types of x and y from Foo to Bar will remove the error. GCC
snapshot 17th August 2019 produces no error. The error message follows:
constexpr_rvalue.cpp:10:17: error: constexpr variable 'x' must be initialized
by a constant expression
constexpr Foo x = jam(y);
^ ~~~~~~
constexpr_rvalue.cpp:10:21: note: read of non-constexpr variable 'y' is not
allowed in a constant expression
constexpr Foo x = jam(y);
^
constexpr_rvalue.cpp:10:21: note: in call to 'Foo(y)'
constexpr_rvalue.cpp:9:7: note: declared here
Foo y;
^
1 error generated.
--
You are receiving this mail because:
You are on the CC list for the bug.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-bugs/attachments/20190822/c0e35b89/attachment.html>
More information about the llvm-bugs
mailing list