Created attachment 34140 [details] A header file, a source file, and a RUNME script using them to demonstrate the problem. Temporarily disabling warnings surrounding template code works fine, except when included in a precompiled header. Then, the warnings remain in effect, and are triggered in any C++ code that uses the template. In my project, this means I just can't use precompiled headers. We are missing out on cutting down our build time as a result. BTW, speaking of precompiled headers, it sucks that `#pragma once` is not allowed when precompiling a header file ("#pragma once in main file"), but that's a minor annoyance - one can switch back to the bad old days of guard macros.
Originally detected in 4.8.2, the problem persists in 4.9.2
Problem persists in gcc 5.2. Sigh.
I can confirm this with GCC 6. I'm not sure if the pragmas are even saved in the pch file. Someone would need to debug what is happening.
Problem persists in gcc 9.3. very very sadly
Problem persists in 10.2
Still buggy in gcc-11 (gcc-11 (Debian 11.1.0-3) 11.1.0) I'll have a look at the code and see if I can fix it.
Oops, sorry, I meant the previous comment for another bug. I don't know if it's solved or not in gcc-11
There is not currently any attempt to store the necessary information in the PCH. Here is a patch submitted for review: https://gcc.gnu.org/pipermail/gcc-patches/2023-November/635648.html
*** Bug 112747 has been marked as a duplicate of this bug. ***