[fpc-devel] [Patch/RFC] Warnings for (in/over)complete case statements

Michael Van Canneyt michael at freepascal.org
Wed Jan 2 12:36:46 CET 2019



On Wed, 2 Jan 2019, Mattias Gaertner via fpc-devel wrote:

>> > Warnings can always be disabled by {$warn NR off} or - I believe - a
>> > command line switch.
>> > One could also decide to have it be a default off warning for the
>> > non ISO modes (FPC, Delphi, MacPas) like some of the string
>> > conversion warnings. 
>> 
>> I would strongly advise to have it off by default for all but the ISO
>> modes.
>> 
>> You have perfectly valid code today (see the example of indexed
>> properties) which would start generating exceptions, and you should
>> not be forced to add a {$ } directive or an "else" clause to a case
>> statement for this.
>
> I do hope you meant warnings, not exceptions.

Yes, sorry, typo :(

>
> 
>> I agree this warning is very useful for enumerated types, but really
>> not for integers. There are too many cases where it would be a false
>> positive.
>
> I have a lot of code with enums, where these warnings will force me to
> do a lot of changes.

I can imagine it.

Maybe the warning should also depend on the range checking on/off switch.

Michael.



More information about the fpc-devel mailing list