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: [email protected]
          Reporter: [email protected]
                CC: [email protected], [email protected]

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.
_______________________________________________
llvm-bugs mailing list
[email protected]
http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-bugs

Reply via email to