[Bug c++/53479] Control flow analysis reports warnings in switch over an enum class even if all possible values have their branches

egall at gwmail dot gwu.edu gcc-bugzilla@gcc.gnu.org
Mon Sep 12 01:11:00 GMT 2016


https://gcc.gnu.org/bugzilla/show_bug.cgi?id=53479

--- Comment #14 from Eric Gallager <egall at gwmail dot gwu.edu> ---
(In reply to Manuel López-Ibáñez from comment #9)
> In summary, neither adding 'default' or 'return' are recommended to silence
> this warning if you think the warning is wrong. If you think the warning
> will always be wrong, use __builtin_unreachable(). If you think it is wrong
> now, but you would like to notice if it stops being wrong, then use
> assert(false).


This is probably an issue for a separate bug, but speaking of
__builtin_unreachable(), now that GCC is going to start recognizing the
lint-style comment of:
/* FALLTHROUGH */
for the benefit of -Wimplicit-fallthrough, could it also start recognizing the
lint-style comment of:
/* NOTREACHED */
as a synonym for __builtin_unreachable()? I've seen comments like that in a lot
of code, actually, and it'd be a more portable solution than
__builtin_unreachable().


More information about the Gcc-bugs mailing list