https://gcc.gnu.org/bugzilla/show_bug.cgi?id=85125
Marek Polacek <mpolacek at gcc dot gnu.org> changed: What |Removed |Added ---------------------------------------------------------------------------- Keywords| |patch Status|NEW |ASSIGNED CC| |mpolacek at gcc dot gnu.org Assignee|unassigned at gcc dot gnu.org |mpolacek at gcc dot gnu.org --- Comment #5 from Marek Polacek <mpolacek at gcc dot gnu.org> --- Recently I posted a patch for this: https://gcc.gnu.org/ml/gcc-patches/2019-07/msg01914.html With that, the original testcase now gives: 85125.C:6:22: error: non-constant condition for static assertion 6 | static_assert(f()==77, ""); | ~~~^~~~ 85125.C:6:20: in ‘constexpr’ expansion of ‘f()’ 85125.C:3:27: error: modifying a const object ‘(int&)(& i)’ is not allowed in a constant expression 3 | const_cast<int&>(i) = 88; | ~~~~~~~~~~~~~~~~~~~~^~~~ 85125.C:2:17: note: originally declared ‘const’ here 2 | int const i = 77; | ^ and the one from Comment 3 gives: 85125-2.C:12:16: error: non-constant condition for static assertion 12 | static_assert(f()); | ~^~ 85125-2.C:12:16: in ‘constexpr’ expansion of ‘f()’ 85125-2.C:8:12: error: modifying a const object ‘*(int*)s.S::ptr’ is not allowed in a constant expression 8 | *s.ptr = 2; | ~~~~~~~^~~ 85125-2.C:7:16: note: originally declared ‘const’ here 7 | auto const s = S{}; | ^