[fpc-devel] Dangerous optimization in CASE..OF
Martok
listbox at martoks-place.de
Sat Apr 21 13:38:54 CEST 2018
Am 20.04.2018 um 21:35 schrieb Ondrej Pokorny:
> Sven (or anybody else), could you please comment on
> https://bugs.freepascal.org/view.php?id=33603 ? I feel I am getting crazy.
That bug became a textbook example of Cipolla's fourth law, sorry.
> From what I read, there seems to be a difference between FPC and Delphi
> understanding of "enums with holes":
Not even that, the two documentations are not exclusive. Nothing about assigned
enumerated types as documented by FPC excludes Delphi's rules. Which is why I
never understood that:
> Also, the difference is demonstrated in the fact that Delphi and FPC delphi mode allow to define an array of Size. OBJFPC mode doesn't allow it.
It may have something to do with typeinfo (see #27622).
For fpc_read_text_enum et al., a different table is generated, which is correct
even for assigned enumerated types.
> An enumerated type is, in effect, a subrange whose lowest and highest values
> correspond to the lowest and highest ordinalities of the constants in the
> declaration. [...] Only three of these values have names, but the
> others are accessible through typecasts and through routines such as Pred, Succ,
> Inc, and Dec.
The same is true in TP, and by implementation in FPC.
> Therefore I enabled the IS/AS operators on enums with holes only in Delphi mode
> and disabled them in all other modes.
Please do not do this. The other modes are the only ones that really need it, in
Delphi mode, nothing should break on invalid enum values anyway (if it does, it
is a compiler error).
--
Regards,
Martok
Ceterum censeo b32079 esse sanandam.
More information about the fpc-devel
mailing list