On 22 Jul 2010, at 12:06, Martin wrote:

> On 22/07/2010 09:57, Sergei Gorelkin wrote:
>> This is by design. 'const' modifier on ansistring and other 'managed' type 
>> arguments instucts the compiler to omit refcount changes, yielding a faster 
>> code. At the same time it prohibits direct modification to the argument, but 
>> nothing can be done if you modify another location that aliases the argument.
>> If you need proper refcounting, you should pass the argument by value (i.e. 
>> without 'const' modifier).
> 
> So, no need to report as bug then?

Indeed, Sergei is correct. In a language like Pascal, there is no way for the 
compiler to ensure that the constness of parameters is completely observed. 
It's more like a hint of the programmer to the code generator ("the values 
passed to this parameter will not changed, so you can optimize however you like 
based on that assumption") than a semantic condition for the compiler to 
guarantee ("make sure that I do not change values passed to this parameter in 
any way").


Jonas_______________________________________________
fpc-devel maillist  -  [email protected]
http://lists.freepascal.org/mailman/listinfo/fpc-devel

Reply via email to