[Bug other/94165] New: Wrong "warning: this statement may fall through" after __builtin_unreachable().
gjl at gcc dot gnu.org
gcc-bugzilla@gcc.gnu.org
Fri Mar 13 10:47:35 GMT 2020
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=94165
Bug ID: 94165
Summary: Wrong "warning: this statement may fall through" after
__builtin_unreachable().
Product: gcc
Version: 9.2.0
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: other
Assignee: unassigned at gcc dot gnu.org
Reporter: gjl at gcc dot gnu.org
Target Milestone: ---
Created attachment 48026
--> https://gcc.gnu.org/bugzilla/attachment.cgi?id=48026&action=edit
C/C++ test case.
The compiler gcc, g++ incorrectly complain about fall-through case after
__builtin_unreachable().
Compiler test case with
$ g++ -c -W -Wall
w.c: In function ‘int func(int, int)’:
w.c:7:15: warning: this statement may fall through [-Wimplicit-fallthrough=]
(__extension__({ \
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
int _r = error_at (msg); \
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
__builtin_unreachable(); \
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
_r; \
~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
}))
~~~
w.c:15:9: note: in expansion of macro ‘error’
error ("bug");
^~~~~
w.c:16:5: note: here
case 1: case 2:
^~~~
The only route to the fall-through is via __builtin_unreachable(), thus this
warning is wrong.
More information about the Gcc-bugs
mailing list