[fpc-devel] mising ansi string ref increase

Martin lazarus at mfriebe.de
Thu Jul 22 04:10:10 CEST 2010


I have an odd case (bug ?)
But I am unable to reproduce on a simple example.

Debugger output, and assembler both suggests it's in the compilation.
fpc from trunk a few weeks ago. using -OpPENTIUMM   -O1

one procedure is declared as
     procedure SetFoldState(const AValue: String);

another one calls this as follows
     if FPendingFoldState <> '' then
       SetFoldState(FPendingFoldState);

FPendingFoldState is a variable (String) of the object (both methods 
belong to the same object too)

Now in SetFoldstate is a line:
   FPendingFoldState:='';

and after this AValue becomes corrupt

The assembler of the calling code (from -al)
# [6541] if FPendingFoldState <> '' then
     movl    -4(%ebp),%eax
     movl    1352(%eax),%eax
     testl    %eax,%eax
     je    .Lj12594
.Ll3371:
# [6542] SetFoldState(FPendingFoldState);
     movl    -4(%ebp),%eax
     movl    1352(%eax),%edx
     movl    -4(%ebp),%eax
     call    SYNEDIT_TCUSTOMSYNEDIT_$__SETFOLDSTATE$ANSISTRING
.Lj12594:

There is no ansistring inc ref (both methods are in the same file, and 
yes {$H+}

Trying to reproduce in a smaller example did not bring results....

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

Martin





More information about the fpc-devel mailing list