https://gcc.gnu.org/bugzilla/show_bug.cgi?id=116847
--- Comment #6 from Jakub Jelinek <jakub at gcc dot gnu.org> --- At least on i686-linux, I think this is PCH related, moving away the stdc++.h.gch directory makes the warning disappear, so it is some kind of interaction between the diagnostics ignores recorded during PCH writing vs. their later use. Unfortunately simple: [[deprecated]] int foo () { return 42; } template <int N> struct S { #pragma GCC diagnostic push #pragma GCC diagnostic ignored "-Wdeprecated-declarations" static int bar () { return foo (); } #pragma GCC diagnostic pop }; header and #include "pr116847.h" int a = S<0>::bar (); doesn't reproduce that (with PCH).