Compilation gobbles up all RAM then aborts
Original Reporter info from Mantis: bmy92
-
Reporter name: Bernard Marcelly
Original Reporter info from Mantis: bmy92
- Reporter name: Bernard Marcelly
Description:
I have a program using COM Automation. It compiled correctly in Lazarus 1.08, in a few seconds.
Recently I changed the contents of a string and recompiled it. The compiler scanned the source, then stalled using all available RAM (8GB, Win7 Home), aborted and released RAM.
I downloaded Lazarus 1.12 and found the same compilation problem.
After deleting parts of code until compilation worked again, I found the origin. In "Steps to reproduce" is a simplified example that triggers the problem. This code cannot run, it is only for compilation tests.
Steps to reproduce:
With this code the compiler gobbles all RAM, aborts, and does not tell you what is wrong :
Uses ComObj;
procedure TForm1.Button1Click(Sender: TObject);
var
pareil : Boolean;
calcPhotos : variant;
begin
calcPhotos:= CreateOleObject('anything');
pareil:= AnsiSameText(calcPhotos.ADR, 'C:\My Photos');
if pareil then showmessage('OK');
end;
The compiler works correctly with this walk around :
Uses ComObj;
procedure TForm1.Button1Click(Sender: TObject);
var
adrCalcPhotos : WideString; pareil : Boolean;
calcPhotos : variant;
begin
calcPhotos:= CreateOleObject('anything');
adrCalcPhotos:= calcPhotos.ADR; // intermediate variable to help the compiler
pareil:= AnsiSameText(adrCalcPhotos, 'C:\My Photos');
if pareil then showmessage('OK');
end;
It seems that the compiler is disturbed by the construct calcPhotos.ADR as argument of AnsiSameText. It works with the argument calcPhotos. The property name ADR may be of course any other name.
Mantis conversion info:
- Mantis ID: 24916
- OS: Windows 7 Home
- OS Build: SP1
- Platform: PC
- Version: 1.0.12