On 02/07/17 11:59, Yury Sidorov wrote:
Indeed, I've done some tests and found out that when range checking is enabled enums are not checked at all. Even array access with enum index is not checked.
According to docs enums should be range checked:
https://www.freepascal.org/docs-html/prog/progsu65.html#x72-710001.2.65

Range checking code is generated for operations involving enums if, according to the type system, the enum can be out of range. Just like with integer sub-range types.

E.g., this generates a range check error:

{$r+}
type
  tenum = (ea,eb,ec,ed);
  tsubenum = eb..ec;
var
  arr: array[tsubenum] of byte;
  index: tenum;
begin
  index:=ed;
  writeln(arr[index]);
end.


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

Reply via email to