[fpc-devel] Const optimization is a serious bug

Martin fpc at mfriebe.de
Thu Jul 7 18:58:43 CEST 2011


On 07/07/2011 17:47, Alexander Klenin wrote:
> On Fri, Jul 8, 2011 at 03:35, Martin<fpc at mfriebe.de>  wrote:
>> AFAIK, today all that const string does is remove the ref count.
>>
>> So basically you say, because of your reasoning, no one should be able to
>> use such a feature in there code?
> It should do what is semantically natural for "const" -- namely,
> prevent programmer from modifying the variable so declared.
> Cf. "const Integer".
> I understand that "const" meaning in Object Pascal has long
> since lost it's meaning, but still, what it should *not* do
> is breaking user programs unexpectedly
....

> 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...

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)

If that is the case: Should we remove "move" / "fillchar" too? Because 
they can do the same.




More information about the fpc-devel mailing list