Steven Schveighoffer <schvei...@yahoo.com> wrote:

Except the language says what results from your code (casting away const and then mutating) is undefined behavior. This means all bets are off, it can crash your program. I'm unsure how the compiler could take that route, but that's what's in the spec.

Maybe because of the way const works, it never really is undefined, but there will always be that loophole.

The thing is, immutable is implicitly castable to const, and immutable
data could be stored in write-protected memory. Apart from that, I believe
it is safe to cast away const.

--
Simen

Reply via email to