[llvm-bugs] [Bug 38420] New: Unsequenced modifications of variable within a constexpr function used in constant expression context not considered ill-formed
via llvm-bugs
llvm-bugs at lists.llvm.org
Thu Aug 2 05:52:49 PDT 2018
https://bugs.llvm.org/show_bug.cgi?id=38420
Bug ID: 38420
Summary: Unsequenced modifications of variable within a
constexpr function used in constant expression context
not considered ill-formed
Product: clang
Version: trunk
Hardware: PC
OS: All
Status: NEW
Severity: enhancement
Priority: P
Component: C++
Assignee: unassignedclangbugs at nondot.org
Reporter: yaghmour.shafik at gmail.com
CC: dgregor at apple.com, llvm-bugs at lists.llvm.org
Given
constexpr int f(int x) {return x++ + x++;}
int main() {
constexpr int x = 2;
constexpr int y = f(x);
}
clang does not consider the declaration of y ill-formed but I believe it
should.
x++ + x++
is undefined behavior since we have unsequenced modifications to x. See
[intro.execution]p10 http://eel.is/c++draft/intro.execution#10 and this should
be ill-formed in a context requiring a constant expression since undefined
behavior is ill-formed in a constant expression see [expr.cons]p2.6
http://eel.is/c++draft/expr.const#2.6
--
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/20180802/627d2c82/attachment-0001.html>
More information about the llvm-bugs
mailing list