[Bug c++/91264] modifying const-qual object in constexpr context not detected

mpolacek at gcc dot gnu.org gcc-bugzilla@gcc.gnu.org
Fri Jul 26 19:12:00 GMT 2019


https://gcc.gnu.org/bugzilla/show_bug.cgi?id=91264

--- Comment #3 from Marek Polacek <mpolacek at gcc dot gnu.org> ---
Another:

struct X {
  int j;
  constexpr X() : j(0) { }
};

struct Y {
  X x;
  constexpr Y() : x{} { }
};

constexpr void
g ()
{
  constexpr Y y{};
  Y *p = const_cast<Y *>(&y);
  p->x.j = 99;
}

static_assert((g(), 1), "");

I have a patch that handles all the tests in this PR so far.


More information about the Gcc-bugs mailing list