[fpc-devel] Const optimization is a serious bug
Martin
fpc at mfriebe.de
Sat Jul 9 01:14:09 CEST 2011
On 09/07/2011 00:09, Max Vlasov wrote:
> The answer is indirect referencing. it's a workaround that probably
> will solve the problem, but I must admit that I don't know what is the
> exact performance price. The compiler when it detects const s:
> ansistring could switch to passing not the actual address of the
> string, but the address of the variable that holds it. In other words
> passing PString instead of string. In this case no reference counting
> or exception frame is probably created and at the same time, if the
> used string is reallocated occasionally because of a side change, the
> code will not fail because it will just automatically use the new
> modified address.
>
function CRCConstString(constref Str: string): integer;
does what you describe
More information about the fpc-devel
mailing list