[fpc-devel] Dangerous optimization in CASE..OF

Martok listbox at martoks-place.de
Sun Jul 2 14:00:59 CEST 2017


> Is this made safe by always having an else/otherwise? If so, could the 
> compiler at least raise a warning if an enumeration was sparse but there 
> was no else/otherwise to catch unexpected cases?
Interestingly, not in FPC.

This was also always my intuition that the else block is also triggered for
invalid enum values (the docs even literally say that, "If none of the case
constants match the expression value") - and it *is* true in Delphi. In FPC it
is also mostly true, unless you happen to fall into this optimisation.




More information about the fpc-devel mailing list