This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
[Bug other/81582] New: -Wimplicit-fallthrough= wrong warning with -save-temps
- From: "gjl at gcc dot gnu.org" <gcc-bugzilla at gcc dot gnu dot org>
- To: gcc-bugs at gcc dot gnu dot org
- Date: Thu, 27 Jul 2017 09:42:37 +0000
- Subject: [Bug other/81582] New: -Wimplicit-fallthrough= wrong warning with -save-temps
- Auto-submitted: auto-generated
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=81582
Bug ID: 81582
Summary: -Wimplicit-fallthrough= wrong warning with -save-temps
Product: gcc
Version: 8.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: ---
int f1 (int x)
{
switch (x)
{
case 1: x++; // FALLTHRU
case 2: x--; /* FALLTHRU */
case 3: x++;
// FALLTHRU
case 4: return x;
default:
break;
}
return 0;
}
$ gcc-8 wsitch.c -W -S # magic comments work
$ gcc-8 wsitch.c -W -S -save-temps
wsitch.c: In function ‘f1’:
wsitch.c:5:14: warning: this statement may fall through
[-Wimplicit-fallthrough=]
case 1: x++; // FALLTHRU
~^~
wsitch.c:6:5: note: here
case 2: x--; /* FALLTHRU */
^~~~
wsitch.c:6:14: warning: this statement may fall through
[-Wimplicit-fallthrough=]
case 2: x--; /* FALLTHRU */
~^~
wsitch.c:7:5: note: here
case 3: x++;
^~~~
wsitch.c:7:14: warning: this statement may fall through
[-Wimplicit-fallthrough=]
case 3: x++;
~^~
wsitch.c:9:5: note: here
case 4: return x;
^~~~
-save-temps is used during development and also in safety-critical applications
to retain preprosessed files and assembly code for verification or later
inspection.
Dunno how to handle this properly, maybe specs can switch off
-Wimplicit-fallthrough if -save-temps is on.
At least it should be documented that -Wimplict-fallthrough does not work as
expected if -save-temps (and perhaps other options liek -fpreprocessed) is on.
-save-temps should mention that it may raise unexpected warnings from
-Wimplicit-fallthrough.
$ gcc -v
Using built-in specs.
COLLECT_GCC=gcc
COLLECT_LTO_WRAPPER=/srv/local/gnu/install/gcc-8-host/bin/../libexec/gcc/x86_64-pc-linux-gnu/8.0.0/lto-wrapper
Target: x86_64-pc-linux-gnu
Configured with: ../../gcc.gnu.org/bootstrap-trunk/configure
--prefix=/local/gnu/install/gcc-8-host --enable-languages=c,c++
--enable-checking=release --disable-bootstrap
Thread model: posix
gcc version 8.0.0 20170724 (experimental) (GCC)