[fpc-devel] Const optimization is a serious bug
Alexander Klenin
klenin at gmail.com
Thu Jul 7 18:36:29 CEST 2011
On Fri, Jul 8, 2011 at 03:23, Martin <fpc at mfriebe.de> wrote:
> Yes, I use pointers, but it does not matter how I managed to change the
> content of "s". All that matters is, that I broke the promise (assuming s
> was declared const")
No, the whole point it is that it *does* matter.
Direct memory access lets you break anything --
class members' visibility, callstack frames,
built-in data structures like vtables, exceptions, refcounting, anything at all.
That does not mean all those features are useless and we should go back
to programming in assembler.
That also does not mean we should allow arbitrary breakage of those
features since "you can break them anyway".
After all, you can break any string code the code much simpler:
(PInteger(s)-1)^:=-1;
--
Alexander S. Klenin
More information about the fpc-devel
mailing list