James Kuyper <> writes:
[...]
> It's easier if I digress for a moment. Defining an object with a 'const'
> qualifier that applies to the object itself (and not, for instance, to
> something it points at) allows an implementation to store that object in
> read-only memory; attempts to write to such an object have undefined
> behavior. That means that the C standard allows arbitrarily bad things
> to happen if your code makes such an attempt.
[...]
Right. And, to be clear, attempts to write such an object have
undefined behavior whether the implementation chooses to store it
in read-only memory or not. (Optimizing compilers commonly cause
such code to misbehave.)
--
Keith Thompson (The_Other_Keith)
kst- <http://www.ghoti.net/~kst>
Will write code for food.
"We must do something. This is something. Therefore, we must do this."
-- Antony Jay and Jonathan Lynn, "Yes Minister"