[llvm-bugs] [Bug 42602] New: Dereferencing an initilizer_list::begin() is not treated as a constant expression
via llvm-bugs
llvm-bugs at lists.llvm.org
Fri Jul 12 08:25:12 PDT 2019
https://bugs.llvm.org/show_bug.cgi?id=42602
Bug ID: 42602
Summary: Dereferencing an initilizer_list::begin() is not
treated as a constant expression
Product: clang
Version: trunk
Hardware: PC
OS: Linux
Status: NEW
Severity: enhancement
Priority: P
Component: C++11
Assignee: unassignedclangbugs at nondot.org
Reporter: antoshkka at gmail.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
Following example does not compile in C++11 and later std modes:
#include <initializer_list>
constexpr std::initializer_list<unsigned> i_list = {10u};
unsigned test() {
constexpr unsigned v = *i_list.begin();
return v;
}
Errors:
<source>:6:24: error: constexpr variable 'v' must be initialized by a constant
expression
constexpr unsigned v = *i_list.begin();
^ ~~~~~~~~~~~~~~~
<source>:6:28: note: read of temporary is not allowed in a constant expression
outside the expression that created the temporary
constexpr unsigned v = *i_list.begin();
^
<source>:3:52: note: temporary created here
constexpr std::initializer_list<unsigned> i_list = {10u};
--
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/20190712/e39673aa/attachment.html>
More information about the llvm-bugs
mailing list