[fpc-pascal] const parameter writeable
L505
fpc505 at z505.com
Sat Apr 29 23:11:16 CEST 2006
Are const parameters supposed to ensure read only access?
If so how come one can write to a typed pointer?
program project1;
{$mode objfpc}{$H+}
type
PSomeRec = ^TSomeRec;
TSomeRec = record
a: string;
b: string;
end;
procedure ChangeRec1(const Rec: PSomeRec);
begin
Rec^.a:= 'string A';
end;
var
RecPtr: PSomeRec;
begin
new(RecPtr);
ChangeRec1(RecPtr);
writeln(RecPtr^.a);
dispose(RecPtr);
readln;
end.
More information about the fpc-pascal
mailing list