We are catching warnings from GCC 7 for implicit fall through in a switch statement. Previously, we cleared them under Clang (that's the reason for the comment seen below):
g++ -DNDEBUG -g2 -O3 -std=c++17 -Wall -Wextra -fPIC -c authenc.cppasn.cpp: In member function ‘void EncodedObjectFilter::Put(const byte*, size_t)’:asn.cpp:359:18: warning: this statement may fall through [-Wimplicit-fallthrough=] m_state = BODY; // fall through ^asn.cpp:361:3: note: here case BODY: ^~~~
The GCC manual states to use __attribute__ ((fallthrough))
, but its not portable. The manual also states "... it is also possible to add a fallthrough comment to silence the warning", but it only offer FALLTHRU
(is this really the only choice?):
switch (cond) { case 1: bar (0); /* FALLTHRU */ default:… }
Is there a portable way to clear the fall through warning for both Clang and GCC? If so, then what is it?