[fpc-devel] Const optimization is a serious bug

Florian Klämpfl florian at freepascal.org
Thu Jul 7 19:22:27 CEST 2011


Am 07.07.2011 19:14, schrieb Alexander Klenin:
> On Fri, Jul 8, 2011 at 04:06, Florian Klämpfl <florian at freepascal.org> wrote:
>> Am 07.07.2011 19:00, schrieb Alexander Klenin:
>>> Currently, there are four meaninigs of "const":
>>> 1) "Const by value" -- like Integer
>>> 2) "Const by reference" -- like shortstring
>>> 3) "Const by reference, but not really const" -- like objects
>>> 4) "Const by value, excapt rare breakage" -- AnsiString
>>>   (and interfaces, but let's not touch that can of worms in this thread :-) )
>>>
>>> I propose to remove meaning (4).
>>>
>>
>> Unlogical. 2) and 4) are coupled.
> 
> This whole construct is unlogical. Logically, "const a" should mean
> just "assignment to a is a compile-time error".
> But this is not achievable due to compatibility reasons.
> Still, I suggest that (4) is a (small, but still) evil, and sould be removed.

Why? 2) is exactly the same? The const contract with the compiler is broken.

Besides this, people like Martin Schreiber won't be happy if a procedure
suddently eats hundreds of extra clock cycles for nothing.





More information about the fpc-devel mailing list