[fpc-devel] Const optimization is a serious bug
Martin
fpc at mfriebe.de
Tue Jul 5 19:47:54 CEST 2011
On 05/07/2011 18:27, José Mejuto wrote:
> This changes should be detected ?
>
> var
> a: ansistring;
>
> procedure DoSomehting(const v: ansistring);
> begin
> a[1]:='a';
> end;
>
> begin
> a:='b';
> DoSomething(a);
> end.
It would probably best to detect this changes too.
But since it would be more of a performance penality, i would like to
see it as an option of it's own. (even if only used in
debug/development, the penalty could be severe enough to hinter development)
Why detect those?
Well at current such a trick could actually be used intentionally. and
it could work well, if done correctly.
But I expect this behaviour is not defined/documented.
If the optimizer improves, the optimizer could do thinks that would make
any code fail, if it uses such tricks. So better to let people know now,
that it isn't safe.
More information about the fpc-devel
mailing list