* [PATCH] tests: Add break to avoid implicit-fallthrough warning
@ 2019-12-06 14:42 Mark Wielaard
2019-12-06 16:21 ` Florian Weimer
0 siblings, 1 reply; 3+ messages in thread
From: Mark Wielaard @ 2019-12-06 14:42 UTC (permalink / raw)
To: elfutils-devel; +Cc: 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.
Signed-off-by: Mark Wielaard <mark@klomp.org>
---
tests/ChangeLog | 4 ++++
tests/backtrace-data.c | 1 +
2 files changed, 5 insertions(+)
diff --git a/tests/ChangeLog b/tests/ChangeLog
index 70100de4..fb881e76 100644
--- a/tests/ChangeLog
+++ b/tests/ChangeLog
@@ -1,3 +1,7 @@
+2019-12-06 Mark Wielaard <mark@klomp.org>
+
+ * backtrace-data.c (main): Add break after assert.
+
2019-12-05 Mark Wielaard <mark@klomp.org>
* run-elfclassify.sh: Run elfcompress under testrun.
diff --git a/tests/backtrace-data.c b/tests/backtrace-data.c
index 907b4780..c81880d9 100644
--- a/tests/backtrace-data.c
+++ b/tests/backtrace-data.c
@@ -280,6 +280,7 @@ main (int argc __attribute__ ((unused)), char **argv __attribute__ ((unused)))
{
case -1:
assert (0);
+ break;
case 0:;
long l = ptrace (PTRACE_TRACEME, 0, NULL, NULL);
assert (l == 0);
--
2.20.1
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH] tests: Add break to avoid implicit-fallthrough warning
2019-12-06 14:42 [PATCH] tests: Add break to avoid implicit-fallthrough warning Mark Wielaard
@ 2019-12-06 16:21 ` Florian Weimer
2019-12-06 21:26 ` Mark Wielaard
0 siblings, 1 reply; 3+ messages in thread
From: Florian Weimer @ 2019-12-06 16:21 UTC (permalink / raw)
To: Mark Wielaard; +Cc: elfutils-devel
* 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.
Thanks,
Florian
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH] tests: Add break to avoid implicit-fallthrough warning
2019-12-06 16:21 ` Florian Weimer
@ 2019-12-06 21:26 ` Mark Wielaard
0 siblings, 0 replies; 3+ messages in thread
From: Mark Wielaard @ 2019-12-06 21:26 UTC (permalink / raw)
To: Florian Weimer; +Cc: elfutils-devel
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
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2019-12-06 21:26 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-12-06 14:42 [PATCH] tests: Add break to avoid implicit-fallthrough warning Mark Wielaard
2019-12-06 16:21 ` Florian Weimer
2019-12-06 21:26 ` Mark Wielaard
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).