On 28/06/2017 20:03, Martok wrote:
Interestingly, I just ran into "bad" code generation with exactly the properties
discussed in this thread.
Because every declared element is covered, the generated code for it ends up
being a computed goto:
and most importantly, not into any else statement.

No, it is not bad code generation.
It is exactly the expected result. At least that is what I understood from previous mails in this thread, specifically (in the context of out-of-range input):

Jonas Maebe wrote:
That is why I said "If range checking is off there or disabled via an explicit type cast, then the result is undefined by definition."

"undefined result" does include the possibility of a crash.

This is the same as accessing an
  Array[enum] of foo;
if enum is out of range, then it may crash, or behave in any undefined way.

The only thing that could be added here is, that if dfa detects that all enums are used in a case statement, and yet there is an "else", then it should warn about "unreachable code".

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

Reply via email to