This could be related to bug 53431, though this report is about C and not C++. Actually I had thought that "-save-temps" just dumps the internal state, but that does not seem to be true. The following code: #pragma GCC diagnostic ignored "-Wundef" #if FOO #endif int main (void) { return 42; } compiled with gcc-4.9 -Wundef -Werror -save-temps -c bug_wundef.c gives: bug_wundef.c:2:5: error: "FOO" is not defined [-Werror=undef] #if FOO ^ cc1: all warnings being treated as errors On the contrary gcc-4.9 -Wundef -Werror -c bug_wundef.c does not give any error.
Does it go through c-ppoutput.c(scan_translation_unit)? If so, this is the same issue as PR53920.
Still a problem in 2021 with gcc-11.1.0
It is indeed a dup of PR53920. Also, I have a patch awaiting review for PR53431; that fixes all 3. *** This bug has been marked as a duplicate of bug 53920 ***