Peter Vreman wrote 5 lines
The example that is provided doesn't fail. Because when calling foo the value of -4(%ebp) is
loaded in %eax and that value is used in the function foo. The setlength() will create a new
string and store that at -4(%ebp) of the calling function. But doesn't change the original
parameter value in %eax (and also stored also at (%esp) in foo).
Hmm... It doesn't fail for me either now, although I've seen it failing with my own eyes before submitting it the first time :/
Probably I've oversimplified the example.
The failing function in Lazarus code is CreateRelativePath in components/codetools/fileprocs.pas, being called (second occurrence) from TBaseCompilerOptions.MakeOptionsString (ide/compileroptions.pp). That code is much more complex than the example, and what's happening there is not in the testsuite, because my patch wasn't causing testsuite failures.
I'll be digging further in.
Sergei