https://llvm.org/bugs/show_bug.cgi?id=27989
Bug ID: 27989 Summary: Subexpression not valid in a constant expression even when it is valid Product: clang Version: 3.8 Hardware: PC OS: Linux Status: NEW Severity: normal Priority: P Component: C++14 Assignee: unassignedclangb...@nondot.org Reporter: michele.ca...@gmail.com CC: llvm-bugs@lists.llvm.org Classification: Unclassified Consider the following code: template<int... V> static constexpr int f(int v) { int a[] = { (v ^= V, 0)... }; // Line 3 return v; } static constexpr int i = f<0x00>(0x11); // Line 7 int main() { } It doesn't compile with the following error: main.cpp:7:22: error: constexpr variable 'i' must be initialized by a constant expression [...] main.cpp:3:23: note: subexpression not valid in a constant expression Note that it doesn't work as well even if no templates are involved: static constexpr int mix(int v, int u) { int a[] = { (v ^= u, 0) }; return v; } static constexpr int mf = mix(0x11, 0x00); int main() { } For such kind of assignments are allowed in constant expressions, it should compile. -- You are receiving this mail because: You are on the CC list for the bug.
_______________________________________________ llvm-bugs mailing list llvm-bugs@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-bugs