https://gcc.gnu.org/bugzilla/show_bug.cgi?id=103334
Bug ID: 103334 Summary: missing -Wc++-compat for a function redeclared with different qualifiers Product: gcc Version: 12.0 Status: UNCONFIRMED Severity: normal Priority: P3 Component: c Assignee: unassigned at gcc dot gnu.org Reporter: msebor at gcc dot gnu.org Target Milestone: --- Redeclaring a function that differs only in the qualifiers on the return type is rejected by G++ in all C++ modes but not diagnosed by GCC in C mode. The warbing should be enhanced to diagnose that as well (-Wignored-qualifiers is enabled by -Wextra but not -Wall). $ cat z.c && gcc -O2 -S -Wall -Wextra -Wc++-compat z.c const int f (void); volatile int f (void); z.c:1:1: warning: type qualifiers ignored on function return type [-Wignored-qualifiers] 1 | const int f (void); | ^~~~~ z.c:2:1: warning: type qualifiers ignored on function return type [-Wignored-qualifiers] 2 | volatile int f (void); | ^~~~~~~~ Compilation error for the same code with G++: $ g++ -O2 -S -Wall -Wextra -std=c++98 -xc++ z.c z.c:1:1: warning: type qualifiers ignored on function return type [-Wignored-qualifiers] 1 | const int f (void); | ^~~~~ z.c:2:1: warning: type qualifiers ignored on function return type [-Wignored-qualifiers] 2 | volatile int f (void); | ^~~~~~~~ z.c:2:14: error: ambiguating new declaration of ‘volatile int f()’ 2 | volatile int f (void); | ^ z.c:1:11: note: old declaration ‘const int f()’ 1 | const int f (void); | ^