[Bug c++/94074] bogus modifying a const object error with const COMPONENT_REF
mpolacek at gcc dot gnu.org
gcc-bugzilla@gcc.gnu.org
Fri Mar 6 20:19:00 GMT 2020
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" }
More information about the Gcc-bugs
mailing list