From: | Kyotaro HORIGUCHI <horiguchi(dot)kyotaro(at)lab(dot)ntt(dot)co(dot)jp> |
---|---|
To: | tgl(at)sss(dot)pgh(dot)pa(dot)us |
Cc: | andres(at)anarazel(dot)de, pgsql-hackers(at)postgresql(dot)org |
Subject: | Re: Use an enum for RELKIND_*? |
Date: | 2019-01-24 10:44:28 |
Message-ID: | 20190124.194428.92612634.horiguchi.kyotaro@lab.ntt.co.jp |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-hackers |
At Wed, 19 Dec 2018 09:55:22 -0500, Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us> wrote in <10268(dot)1545231322(at)sss(dot)pgh(dot)pa(dot)us>
> Andres Freund <andres(at)anarazel(dot)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
From | Date | Subject | |
---|---|---|---|
Next Message | Greg Stark | 2019-01-24 11:21:02 | Re: Use an enum for RELKIND_*? |
Previous Message | Amit Langote | 2019-01-24 10:29:29 | Re: using expression syntax for partition bounds |