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
_______________________________________________
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal

Reply via email to