Bug 64117 - warning control #pragmas in precompiled headers are not obeyed for template code
Summary: warning control #pragmas in precompiled headers are not obeyed for template code
Status: NEW
Alias: None
Product: gcc
Classification: Unclassified
Component: pch (show other bugs)
Version: 4.9.2
: P3 enhancement
Target Milestone: ---
Assignee: Not yet assigned to anyone
URL: https://gcc.gnu.org/pipermail/gcc-pat...
Keywords: diagnostic, patch
: 112747 (view as bug list)
Depends on:
Blocks:
 
Reported: 2014-11-29 15:52 UTC by Oren Ben-Kiki
Modified: 2023-11-28 17:12 UTC (History)
7 users (show)

See Also:
Host:
Target:
Build:
Known to work:
Known to fail:
Last reconfirmed: 2023-11-07 00:00:00


Attachments
A header file, a source file, and a RUNME script using them to demonstrate the problem. (464 bytes, application/x-gzip)
2014-11-29 15:52 UTC, Oren Ben-Kiki
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Oren Ben-Kiki 2014-11-29 15:52:41 UTC
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.
Comment 1 Oren Ben-Kiki 2014-12-19 13:11:41 UTC
Originally detected in 4.8.2, the problem persists in 4.9.2
Comment 2 Oren Ben-Kiki 2015-08-23 14:16:33 UTC
Problem persists in gcc 5.2. Sigh.
Comment 3 Manuel López-Ibáñez 2015-08-23 15:33:39 UTC
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.
Comment 4 fsmoke 2020-06-24 12:30:36 UTC
Problem persists in gcc 9.3.

very very sadly
Comment 5 Chih-cheng Rex Yuan 2021-02-25 11:32:29 UTC
Problem persists in 10.2
Comment 6 Alejandro Colomar 2021-06-14 19:02:35 UTC
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.
Comment 7 Alejandro Colomar 2021-06-14 19:04:52 UTC
Oops, sorry, I meant the previous comment for another bug.  I don't know if it's solved or not in gcc-11
Comment 8 Lewis Hyatt 2023-11-08 03:24:08 UTC
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
Comment 9 Lewis Hyatt 2023-11-28 17:12:22 UTC
*** Bug 112747 has been marked as a duplicate of this bug. ***