On 03.07.2019 08:58, Ondrej Pokorny wrote:
BTW I was always convinced that an explicit typecast switches off range checking. And now I open the documentation https://www.freepascal.org/docs-html/prog/progsu65.html and I read this: (citation) /If, at run-time, an index or enumeration type is specified that is out of the declared range of the compiler, then a run-time error is generated, and the program exits with exit code 201. This can happen when doing a typecast (implicit or explicit) on an enumeration type or subrange type./
More fun: program Project1; {$R+} type TSubRange = 1..2; var S: TSubRange; begin S := Default(TSubRange); Writeln(S); end. compiles and runs just fine. Why? This does not compile: program Project1; {$R+} type TSubRange = 1..2; var S: TSubRange; begin S := 0; Writeln(S); end. Ondrej
_______________________________________________ fpc-devel maillist - fpc-devel@lists.freepascal.org https://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-devel