https://gcc.gnu.org/bugzilla/show_bug.cgi?id=91264
Bug ID: 91264 Summary: modifying const-qual object in constexpr context not detected Product: gcc Version: 10.0 Status: UNCONFIRMED Severity: normal Priority: P3 Component: c++ Assignee: unassigned at gcc dot gnu.org Reporter: mpolacek at gcc dot gnu.org Target Milestone: --- constexpr int foo () { const int i = 5; const_cast<int &>(i) = 10; return i; } int main () { int i = foo (); } $ ./cc1plus -quiet w.C # nothing $ clang++ -c w.C w.C:3:1: error: constexpr function never produces a constant expression [-Winvalid-constexpr] foo () ^ w.C:6:24: note: modification of object of const-qualified type 'const int' is not allowed in a constant expression const_cast<int &>(i) = 10; ^ 1 error generated.