[fpc-devel] Const optimization is a serious bug
Alexander Klenin
klenin at gmail.com
Thu Jul 7 19:29:08 CEST 2011
On Fri, Jul 8, 2011 at 03:58, Martin <fpc at mfriebe.de> wrote:
> On 07/07/2011 17:47, Alexander Klenin wrote:
>> Also note that, implemented properly, removal of incref/decref calls
>> should not depend on any const declarations, it can be performed even
>> for non-const strings.
>>
> Differnet feature. Nice to have...
Agreed.
> But no compiler can identify every occurrence where the ref count can be
> ommitted.
>
> so it still stands:
> What you want, is the removal of a feature from pascal. The feature for the
> programmer to explicitly skip the ref count (at the programmers own risk)
Well, don't you think that "expliciitly ask to skip refcount" feature
is quite different from "constant parameter"?
At some stage, semantic annotation got conflated with a specific
optimization it allowed.
I propose to decouple them -- let the "const" mean "constant"
(which, by the way, can not be achieved currently, so it would be new feature),
and do refcount skipping only if safe
(or, for the really critical codepaths, introduce a separate,
explicitly-named annotation,
something like "const norefcount").
> If that is the case: Should we remove "move" / "fillchar" too? Because they
> can do the same.
There is Move and there is assignment.
You would not advocate always perform "Move" on assignment,
beause it is slightly faster, even if it breaks some code like
AnsiString assignment?
--
Alexander S. Klenin
More information about the fpc-devel
mailing list