https://gcc.gnu.org/bugzilla/show_bug.cgi?id=106423
Bug ID: 106423
Summary: -Wc++20-compat diagnostics not suppressed by #pragma
GCC diagnostic ignored
Product: gcc
Version: 10.0
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: c++
Assignee: unassigned at gcc dot gnu.org
Reporter: tom at honermann dot net
Target Milestone: ---
As demonstrated at https://godbolt.org/z/GoTqPTcM3, use of gcc's '#pragma GCC
diagnostic ignored "-Wc++20-compat"' directive fails to suppress -Wc++20-compat
enabled diagnostics. gcc versions 10 and up are affected.
$ cat t.cpp
#pragma GCC diagnostic ignored "-Wc++20-compat"
int constinit;
$ gcc -c -std=c++17 -Wc++20-compat t.cpp
t.cpp:2:5: warning: identifier ‘constinit’ is a keyword in C++20
[-Wc++20-compat]
2 | int constinit;
| ^~~~~~~~~