{$APPTYPE CONSOLE}
{$TYPEDADDRESS ON}
{$LONGSTRINGS OFF}
{$WRITEABLECONST OFF}
{ --------------------------------------------------------------------------- }
program _writeableconst;
const
ArrayConst : array[0..1] of
record
t : pchar;
l : DWORD
end =
(
(t: 'some text'; l: 0),
(t: 'more text'; l: 0)
);
v : DWORD = 0;
var
i : integer;
begin
for i := low(ArrayConst) to high(ArrayConst) do
begin
with ArrayConst[i] do
begin
{ assign to a non writeable constant, yet NO compiler error emitted }
{ BUT, you get an access violation at runtime (as there should be) }
l := i + 10; { set to any value }
end;
end;
{ this statement causes a compile time error - as it should }
v := 1; { compile error - as expected }
end.