https://gcc.gnu.org/bugzilla/show_bug.cgi?id=99014
Bug ID: 99014 Summary: -Werror -Wno-foo with foo unrecognized results in an error if another warning is emitted Product: gcc Version: 9.3.0 Status: UNCONFIRMED Severity: normal Priority: P3 Component: c Assignee: unassigned at gcc dot gnu.org Reporter: vincent-gcc at vinc17 dot net Target Milestone: --- Consider the following tst.c file: int f (void) { #ifdef F int i; #endif return 0; } With gcc-9 (Debian 9.3.0-22) 9.3.0: zira:~> gcc-9 -Wextra -Werror -Wno-error=unused-variable -Wno-foo -c tst.c zira:~> gcc-9 -Wextra -Werror -Wno-error=unused-variable -Wno-foo -c tst.c -DF tst.c: In function ‘f’: tst.c:4:7: warning: unused variable ‘i’ [-Wunused-variable] 4 | int i; | ^ tst.c: At top level: cc1: error: unrecognized command line option ‘-Wno-foo’ [-Werror] cc1: all warnings being treated as errors while -Wno-foo should be ignored as usual. Ditto with gcc-8 (Debian 8.4.0-7) 8.4.0. With gcc-10 (Debian 10.2.1-6) 10.2.1 20210110, this is OK, -Wno-foo just emits a non-fatal note: zira:~> gcc-10 -Wextra -Werror -Wno-error=unused-variable -Wno-foo -c tst.c zira:~> gcc-10 -Wextra -Werror -Wno-error=unused-variable -Wno-foo -c tst.c -DF tst.c: In function ‘f’: tst.c:4:7: warning: unused variable ‘i’ [-Wunused-variable] 4 | int i; | ^ tst.c: At top level: cc1: note: unrecognized command-line option ‘-Wno-foo’ may have been intended to silence earlier diagnostics