Clang differs slightly than GCC for a few patterns:
switch (x) { case 0: ++x; default: break; } switch (x) { case 0: ++x; default: goto y; } y:; switch (x) { case 0: ++x; default: return; }
Clang will warn, GCC will not. This is making it excessively painful to
enable -Wimplicit-fallthrough for Linux kernel builds with Clang, see
below link in which 140 patches were sent to try to fix up these
differences in kernel code. Kernel and GCC developers point out that
Clang should not warn in this case.
Intentionally diverge from GCC in one case:
switch (x) { case 0: ++x; default: ; }
Clang will warn, GCC will not.
Fixes: https://github.com/ClangBuiltLinux/linux/issues/636
Link: https://github.com/ClangBuiltLinux/linux/issues/236
Link: https://gcc.gnu.org/bugzilla/show_bug.cgi?id=91432
Link: https://lore.kernel.org/lkml/CANiq72=E_gEVvqUUTSqU4zegC2=yZSTM4b=4G-iofp6d3=UgWQ@mail.gmail.com/T/#t
Signed-off-by: Nick Desaulniers <ndesaulniers@google.com>
is there maybe a nicer way to do this using std::bind or std::mem_fn?