On 22/07/2010 11:06, Martin wrote:
On 22/07/2010 09:57, Sergei Gorelkin wrote:
Martin пишет:

Anyone any idea, if there s any code that could cause such an "optimization" ?

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?

Btw, just an idea.

A possibility (probably quicker than inc-string-ref) would be:
In the case that other (none local) strings are used (and modified) inside such a function/procedure then they are compared (just the pointer) to the const argument. If equal, then inc-ref can still be called.

Optimization (later) could spot localization of such checks => if the other string is modified only in a certain spot, (if something) then checks could be executed only if the conditional block was entered.

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

Reply via email to