[PATCH] tests: Add break to avoid implicit-fallthrough warning

Mark Wielaard mark@klomp.org
Fri Dec 6 21:26:00 GMT 2019


On Fri, 2019-12-06 at 17:21 +0100, Florian Weimer wrote:
> * Mark Wielaard:
> 
> > For some reason gcc might fail to recognize the assert (0) will never
> > return and emit an implicit-fallthrough warning. Just add a break to
> > silence it.
> 
> Is this with -DNDEBUG?  assert (0) expands to basically nothing in that
> case.  I'm not sure if we should change that.  We cannot realistically
> emit __builtin_unreachable in that case, I think, because it would make
> writing incorrect asserts *really* risky with -DNDEBUG.

That might also trigger it. But in this case it seems like gcc simply
doesn't fold away the if (expr) ... even though expr is clearly 0 and
just warns about the whole statement. It is odd, maybe caused by this
setup not using include files in the standard place? It just seemed
simpler to just add a break then fight with it.

Cheers,

Mark



More information about the Elfutils-devel mailing list