Bug 59566 - [4.8/4.9 regression] g++ preprocessor output includes comments meant for GNU C Library files
Summary: [4.8/4.9 regression] g++ preprocessor output includes comments meant for GNU ...
Status: RESOLVED INVALID
Alias: None
Product: gcc
Classification: Unclassified
Component: preprocessor (show other bugs)
Version: 4.8.0
: P3 normal
Target Milestone: 4.8.3
Assignee: Not yet assigned to anyone
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2013-12-20 04:12 UTC by Geoff Alexander
Modified: 2013-12-20 15:43 UTC (History)
1 user (show)

See Also:
Host:
Target:
Build:
Known to work:
Known to fail:
Last reconfirmed: 2013-12-20 00:00:00


Attachments
Example input and output files (1.48 KB, application/x-gzip)
2013-12-20 04:12 UTC, Geoff Alexander
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Geoff Alexander 2013-12-20 04:12:51 UTC
Created attachment 31484 [details]
Example input and output files

I've found that g++ 4.8.x preprocessor output unexpectedly includes comments meant for GNU C Library files.

To illustrate this problem, I ran the g++ preprocessor on test.hpp using as follows

    g++ -C -E -o test-<gcc-version>.hpp -P test.hpp

With g++ 4.7.3, this generated the expected output file.  However, with g++ 4.8.0, 4.8.1, and 4.8.2 the generated output file unexpectedly contained a number of comments meant for GNU C Library files.
Comment 1 Richard Biener 2013-12-20 10:13:38 UTC
You are using -C, so what do you expect?  Note that since 4.8.x GCC automatically
includes stdc-predef.h (which you can see when you remove the -P option).  The
comment nicely explains in the last sentence:

/* This header is separate from features.h so that the compiler can
   include it implicitly at the start of every compilation.  It must
   not itself include <features.h> or any other header that includes
   <features.h> because the implicit include comes before any feature
   test macros that may be defined in a source file before it first
   explicitly includes a system header.  GCC knows the name of this
   header in order to preinclude it.  */

Thus, it works as designed. No?
Comment 2 Jakub Jelinek 2013-12-20 12:16:37 UTC
Yeah, that is not a bug.
With -ffreestanding, -nostdinc or -fpreprocessed <stdc-predef.h> isn't automatically included, but you then have to deal with the other effects of those options.
Comment 3 Geoff Alexander 2013-12-20 15:43:03 UTC
Richard and Jakub - Thanks for the quick response and explanation.  I was able to use the -nostdinc option to suppress the automatic inclusion of <stdc-predef.h>, which eliminates the unwanted comments.