[fpc-devel] open array and address of "@" / crash, why?
lazarus at mfriebe.de
Sun Mar 30 15:24:46 CEST 2014
The below program compiles fine (and generates no warning (fpc 2.6.2 /
"c" is an open array. But there is no warning when assigning the
[address of c] to a [pointer to dyn array].
Assuming that type safety checks are performed, I would expect a working
pointer. But it does not. The pointer point directly to the 1st element
of the array. So using it a pointer to a dyn-array, crashes.
So what should happen?
- Should this code work?
- Should this code give a compile error?
TA = array of integer;
PA = ^TA;
a : array of integer;
procedure Foo(var c: array of integer; var c1: PA);
writeln(PInteger(c1)^); // writes 100
More information about the fpc-devel