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: unassignedclangb...@nondot.org
Reporter: antosh...@gmail.com
CC: blitzrak...@gmail.com, dgre...@apple.com,
erik.pilking...@gmail.com, llvm-bugs@lists.llvm.org,
richard-l...@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.
_______________________________________________
llvm-bugs mailing list
llvm-bugs@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-bugs