https://gcc.gnu.org/bugzilla/show_bug.cgi?id=117577
Bug ID: 117577
Summary: The compiler flag -w does **not** silence all warnings
Product: gcc
Version: 15.0
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: c
Assignee: unassigned at gcc dot gnu.org
Reporter: carlosgalvezp at gmail dot com
Target Milestone: ---
Example:
typedef void (*PFUNC)(int);
void func(double);
int main()
{
PFUNC x = func;
}
Compiling with "gcc -w main.c", I still get:
<source>: In function 'main':
<source>:7:15: error: initialization of 'PFUNC' {aka 'void (*)(int)'} from
incompatible pointer type 'void (*)(double)' [-Wincompatible-pointer-types]
7 | PFUNC x = func;
| ^~~~
Compiler returned: 1
https://godbolt.org/z/s4eo9Wz7z
I can still suppress the warning explicitly via
-Wno-incompatible-pointer-types, but I would expect "-w" to work here, since
this is a warning (not an error) and -w "Inhibit all warning messages" as per
the docs.
I have seen this issue with other warnings as well. It seems like warnings that
are always active by default (e.g. not opted-in via -Wall, etc) cannot be
suppressed via -w.
Why is that?