[LLVMbugs] [Bug 19741] New: clang incorrectly rejects constexpr constructor which modified member variable in its body
bugzilla-daemon at llvm.org
bugzilla-daemon at llvm.org
Wed May 14 09:10:54 PDT 2014
http://llvm.org/bugs/show_bug.cgi?id=19741
Bug ID: 19741
Summary: clang incorrectly rejects constexpr constructor which
modified member variable in its body
Product: clang
Version: 3.4
Hardware: PC
OS: Windows NT
Status: NEW
Severity: normal
Priority: P
Component: C++1y
Assignee: unassignedclangbugs at nondot.org
Reporter: ytj000 at gmail.com
CC: llvmbugs at cs.uiuc.edu
Classification: Unclassified
struct A {
int a = 0;
constexpr A() { a = 1; }
};
constexpr bool f() {
constexpr A a;
static_assert(a.a == 1, ""); // L1: OK
return a.a == 1;
}
static_assert(f(), ""); // L2: Error, can not modify A::a in constexpr
- Online Compiler URL: http://goo.gl/jni6Em
- Compiler: clang 3.4 (with -std=c++1y)
- System: Linux 3.2
The constructor satisfies all the conditions listed in ยง7.1.5/4 of N3936.
However, clang complains:
clang++ -stdlib=libc++ -std=c++1y a.cpp -c -o a.o -Wall
a.cpp:11:15: error: static_assert expression is not an integral constant
expression
static_assert(f(), ""); // L2: Error
^~~
a.cpp:3:23: note: modification of object of const-qualified type 'const int' is
not allowed in a constant expression
constexpr A() { a = 1; }
^
a.cpp:7:17: note: in call to 'A()'
constexpr A a;
^
a.cpp:11:15: note: in call to 'f()'
static_assert(f(), ""); // L2: Error
^
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/20140514/14eb77f1/attachment.html>
More information about the llvm-bugs
mailing list