[fpc-devel] "Case statement does not handle all possible cases" Warning

J. Gareth Moreton gareth at moreton-family.com
Sun May 19 00:42:57 CEST 2019


Lazy... you've got a bloody cheek.  Well I guess there's no point in me 
contributing anything more if that's how you honestly view me.  I wasn't 
aware of the ISO that dictated that a case block shouldn't just fall 
through until today, and C/C++ and Basic never threw similar errors or 
warnings, so I didn't know this was a thing.

Good day.


On 18/05/2019 22:56, Ralf Quint wrote:
> 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
>
>
>
> <https://www.avast.com/sig-email?utm_medium=email&utm_source=link&utm_campaign=sig-email&utm_content=emailclient&utm_term=icon> 
> 	Virus-free. www.avast.com 
> <https://www.avast.com/sig-email?utm_medium=email&utm_source=link&utm_campaign=sig-email&utm_content=emailclient&utm_term=link> 
>
>
> <#DAB4FAD8-2DD7-40BB-A1B8-4E2AA1F9FDF2>
>
> _______________________________________________
> fpc-devel maillist  -  fpc-devel at lists.freepascal.org
> http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-devel


---
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/eb450f36/attachment.html>


More information about the fpc-devel mailing list