When using optimization (Delphi 6), there's a strange behaviour with data buffer when calling WriteStr.
Looks like the buffer passed to Windows.WriteFile in WriteAsync is not valid long enough.. for some compiler's obscure reasons...
I find it by making a dichotomy with $O+ / $O- options in CPort.pas :)
Inlining WriteStrAsync in WriteStr (I removed the AnsiString cast too) seems to solve the problem, but I couldn't get a clean understanding of this problem.
A cleanerr way to solve this could be to allocate a buffer on the heap in WriteStr, to ensure that buffer stays here during the writefile operation