At Wed, 19 Dec 2018 09:55:22 -0500, Tom Lane <t...@sss.pgh.pa.us> wrote in 
<10268.1545231...@sss.pgh.pa.us>
> Andres Freund <and...@anarazel.de> writes:
> > On 2018-12-18 23:17:54 -0500, Tom Lane wrote:
> >> Yeah, that would sure make things better.  I was considering
> >> something like
> >>
> >>    #ifndef USE_ASSERT_CHECKING
> >>            default:
> >>                elog(ERROR, ...);
> >>    #endif
> 
> > Yea, that's the best I can come up with too.  I think we'd probably want
> > to have the warning available during development mainly, so I'm not sure
> > the "lonely buildfarm animal" approach buys us enough.
> 
> Well, if it's controlled by some dedicated symbol ("CHECK_ENUM_SWITCHES"
> or such) then you could certainly run a test compile with that turned
> on, if you felt the need to.  But I don't really buy the complaint
> that leaving it to the buildfarm to find such problems wouldn't work.
> They're almost always simple, easily-fixed oversights.
> 
> Also, if we wrap all this up in a macro then it'd be possible to do
> other things by adjusting the macro.  I'm envisioning
> 
>       switch ((RelationRelkind) rel->rd_rel->relkind)
>       {
>           case ...
>               ...
> 
>           CHECK_ENUM_SWITCH(RelationRelkind, rel->rd_rel->relkind);
>       }

I might misunderstand something, but my compiler (gcc 7.3.1)
won't be quiet about omitted value even with default:.

>   switch ((x) v)
>   {
>      case A: ...
>      case B: ...
>      default: ...
>   }
> 
> t.c:12:3: warning: enumeration value 'C' not handled in switch [-Wswitch-enum]

Isn't it enough that at least one platform correctly warns that?

regards.

-- 
Kyotaro Horiguchi
NTT Open Source Software Center


Reply via email to