On 05.07.2019 22:44, J. Gareth Moreton wrote:

In the meantime, I've extended your AS/IS patch over here <https://bugs.freepascal.org/view.php?id=33603> to create efficient code for x86 platforms, although currently it only does a range check and won't correctly handle enumerations with holes.  If non-contiguous enumerations are going to be allowed, we'll need to design an algorithm that can cover these holes with the smallest number of Boolean conditions.

IMO handling holes in enumerations is just a pure waste of time and energy. Delphi documents them as valid and the FPC compiler handles them as valid as well. IMO it is just an unnecessary extra added limitation to disable IS/AS on them. Furthermore they are used mainly for very specific needs, so are very marginal. The effort to make this work just doesn't pay off.

Btw. you get a "project1.lpr(7,10) Warning: Case statement does not handle all possible cases" in the program below anyway:

program Project1;
type
  THoleEnum = (two=2, four=4);
var
  E: THoleEnum;
begin
  case E of
    two: ;
    four: ;
  end;
end.

What will you do now, disable case-of for enumerations with holes because the compiler cannot handle the holes correctly in the strict FPC POV way?

Ondrej

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

Reply via email to