[fpc-pascal] default value of a sub range field produces No range Check error
Dennis
dec12 at avidsoft.com.hk
Thu Oct 15 17:58:04 CEST 2015
I tried with fpc 2.6.4
-----------------
program Project1;
uses classes;
type
TSmall = 4..12;
TA=class
public
N : TSmall; //default to 0 after create, should raise range check error
end;
var
A : TA;
begin
A := TA.Create; //no range check error
writeln(A.N); //no range check error
inc(A.N); //range check error
writeln(A.N);
readln;
end.
--------------
the fact that it raises NO range check error during Create and the first
writeln seems weird.
Perhaps the compiler should have a warning when defining a sub-range
field in class, telling users that it will be default to 0.
Dennis
More information about the fpc-pascal
mailing list