https://gcc.gnu.org/bugzilla/show_bug.cgi?id=80253
Bug ID: 80253 Summary: Optimization silences __attribute__((fallthrough)) warning Product: gcc Version: 7.0 Status: UNCONFIRMED Severity: normal Priority: P3 Component: c Assignee: unassigned at gcc dot gnu.org Reporter: sirl at gcc dot gnu.org Target Milestone: --- Created attachment 41073 --> https://gcc.gnu.org/bugzilla/attachment.cgi?id=41073&action=edit testcase The attached testcase issues 2 warnings with -O0 and only 1 warning with -O1 or higher. I believe 2 warnings should be issued in both cases. # gcc-trunk -Wall -c fallthrough-1.c -O0 fallthrough-1.c: In function 'test': fallthrough-1.c:4:21: warning: attribute 'fallthrough' not preceding a case label or default label #define FALLTHROUGH __attribute__((fallthrough)) ^ fallthrough-1.c:25:5: note: in expansion of macro 'FALLTHROUGH' FALLTHROUGH; ^~~~~~~~~~~ fallthrough-1.c:4:21: warning: attribute 'fallthrough' not preceding a case label or default label #define FALLTHROUGH __attribute__((fallthrough)) ^ fallthrough-1.c:32:4: note: in expansion of macro 'FALLTHROUGH' FALLTHROUGH; ^~~~~~~~~~~ # gcc-trunk -Wall -c fallthrough-1.c -O1 fallthrough-1.c: In function 'test': fallthrough-1.c:4:21: warning: attribute 'fallthrough' not preceding a case label or default label #define FALLTHROUGH __attribute__((fallthrough)) ^ fallthrough-1.c:25:5: note: in expansion of macro 'FALLTHROUGH' FALLTHROUGH; ^~~~~~~~~~~