[fpc-devel] "Case statement does not handle all possible cases" Warning
Ralf Quint
freedos.la at gmail.com
Sat May 18 23:56:49 CEST 2019
On 5/18/2019 4:30 AM, J. Gareth Moreton wrote:
> Hi everyone,
>
> So it looks like this new warning has appeared as part of the data
> flow analysis of -O4. The thing is, I personally have a problem with
> this being a warning, because there's nothing inherently wrong with
> not covering every case branch or omitting an else block (especially
> if one isn't needed). Adding "else ;" everywhere seems to just cause
> bloat.
>
> Still, code style aside, can I suggest the warning be downgraded into
> a hint? Warnings should indicate the possibility of unstable code due
> to uninitialised values, for example, and DFA should be able to detect
> that anyway as a separate warning (e.g. if a case block doesn't
> initialise an output value in all of its branches).
Sorry, but you seem to suffer from the "lazy programmer syndrome". A
warning is correct, as a case of unhandled */case/* statement can indeed
lead to unexpected side effects. While there could be cases where you
might want to react with the /*case*/ statement to only certain
conditions (and can safely assume that all other conditions don't do ill
effects), there is also the case where an unknown/unexpected condition
is passed and that can have dire consequences, and should be properly
acted upon, by the /*else*/ clause within the case statement...
Ralf
---
This email has been checked for viruses by Avast antivirus software.
https://www.avast.com/antivirus
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.freepascal.org/pipermail/fpc-devel/attachments/20190518/ab167ee9/attachment.html>
More information about the fpc-devel
mailing list