Compiler crash with Access Violation instead of error message under certain conditions
Original Reporter info from Mantis: lenz
-
Reporter name: Lenz Kessler
Original Reporter info from Mantis: lenz
- Reporter name: Lenz Kessler
Description:
The following code causes compiler to crash with Access Violation (paste it into existing project, e.g. Windows x86):
{$MODE DELPHI}
type
TDateTimeStamp = record
Value: Int64;
end;
const
InvalidDateTimeStampValue = Low(Int64);
type
TDateTimeStampHelper = record helper for TDateTimeStamp
const Invalid: TDateTimeStamp = (Value: InvalidDateTimeStampValue);
end;
TSomeOtherClass = class
end;
TSomeClass = class
private
Data: array of TSomeOtherClass;
public
procedure Test;
end;
procedure TSomeClass.Test;
begin
Data.HelloWorld;
end;
Compiling above will show:
Fatal: Compilation aborted
An unhandled exception occurred at $00437C5E:
EAccessViolation: Access violation
$00437C5E
If the code is commented starting from "TDateTimeStamp" to "TDateTimeStampHelper", leaving only "TSomeOtherClass" and "TSomeClass" declarations, it will correctly display:
test.pas(41,8) Fatal: Syntax error, "CREATE" expected but "HELLOWORLD" found
Fatal: Compilation aborted
That issue was discovered by using Android compiler, but it occurs with Windows compiler too. Reproducible Android project is attached.
Mantis conversion info:
- Mantis ID: 25504
- OS: Windows, Android
- Build: trunk revision 26385
- Platform: x86, x64, Android
- Version: 2.7.1
- Fixed in version: 3.0.0
- Fixed in revision: 26459 (#5fc4af09)
- Monitored by: » lenz (Lenz Kessler)