Dennis wrote:
the fact that it raises NO range check error during Create and the first
writeln seems weird.

Range checks are inserted when a conversion from type A to type B occurs, with A <> B (and then it checks whether the value is a valid "type B" value). Values of fields in constructors are not explicitly assigned, the instance is simply backed by a memory area that has been set to zero.

Perhaps the compiler should have a warning when defining a sub-range
field in class, telling users that it will be default to 0.

The documentation says this already: http://www.freepascal.org/docs-html/3.0.0/ref/refsu24.html ("The example demonstrates that values of fields are initialized with zero (or the equivalent of zero for non ordinal types: empty string, empty array and so on).") A warning would be overkill, I think.


Jonas
_______________________________________________
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal

Reply via email to