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

--- Comment #2 from Marek Polacek <mpolacek at gcc dot gnu.org> ---
And this should be diagnosed but isn't:

struct X {
  int i;
};

template <typename T>
struct S {
  const X x;
  constexpr S(int) : x{}
  {
    const_cast<X&>(x).i = 19; // { dg-error "modifying a const object" }
  }
};

constexpr S<int> p = { 10 }; // { dg-message "originally declared" }

Reply via email to