https://gcc.gnu.org/bugzilla/show_bug.cgi?id=96996
--- Comment #5 from Matthijs Kooijman <matthijs at stdin dot nl> --- > But isn't there const_cast<> to change the value of p? Yes, that makes it possible to write to a const object, but actually doing so is undefined behavior (see [dcl.type.cv] I quoted above). The spec even makes this explicit about const_cast, [expr.const.cast] says: > [ Note: Depending on the type of the object, a write operation through > the pointer, lvalue or pointer to data member resulting from a > const_cast that casts away a const-qualifier may produce undefined > behavior (7.1.6.1). — end note ]