View Issue Details

IDProjectCategoryView StatusLast Update
00019251003.1(2024)/Issue8Shell and Utilitiespublic2025-05-16 06:05
ReporterLove4Boobies Assigned To 
PrioritynormalSeverityObjectionTypeError
Status Interpretation RequiredResolutionAccepted As Marked 
NameBogdan Barbu
Organization
User Reference
Sectionc17
Page Numberhttps://pubs.opengroup.org/onlinepubs/9799919799/utilities/c17.html
Line NumberSTDOUT section
Interp StatusProposed
Final Accepted Textsee 0001925:0007184
Summary0001925: c17 -E output is incompatible with existing implementations
DescriptionUnder the STDOUT section of the c17 description, POSIX reads:

---
If the -E option is specified, the standard output shall be a text file that represents the results of the preprocessing stage of the language; it may contain extra information appropriate for subsequent compilation passes and shall contain at least one line with the format:

"# %d \"%s\"\n", <line>, <pathname>

for each file processed as a result of a #include directive, unless no other output generated from that file is present in the output, where line is a line number and pathname is the pathname used to open the file.
---

GCC, clang, ICC, EDG, also add flags towards the end of the line. For example, see GCC's documentation:

https://gcc.gnu.org/onlinedocs/cpp/Preprocessor-Output.html

This is important because this is how automatic make dependencies cand be implemented portably under POSIX according to #1325. In fact, this output is used in EXAMPLES on the make page; it is the 4th example in that section. Someone reading the semantics of -E might do something similar to that example, except write the sed part similarly to this do to the assumption that '\n' follows the quoted pathname:

LC_ALL=C sed -En '/^# [1-9][[:digit:]]* "([^"]*)"$$/s//\1/p'

(I put an extra [1-9] in there to exclude the impossible line number 0 which GCC uses for built-in headers.)
Desired ActionEither standardize the flags as well, since they're pretty useful, or make the format less restrictive.
Tagstc1-2024

Activities

nick

2025-05-15 15:52

manager   bugnote:0007184

Interpretation response
------------------------
The standard states the output format for c17 -E, and conforming implementations must conform to this. However, concerns have been raised about this which are being referred to the sponsor.

Rationale:
-------------
None.

Notes to the Editor (not part of this interpretation):
-------------------------------------------------------

Change Page 2673 lines 88033-88036 from:

...
it may contain extra information appropriate for subsequent compilation passes and shall contain at least one line with the format:
"# %d \"%s\"\n", <line>, <pathname>

for each file processed as a result of a #include directive, unless no other output generated from that file is present in the output, where line is a line number and pathname is the pathname used to open the file.


to:


...
it may contain extra information appropriate for subsequent compilation passes and shall contain at least one line with the format:
"# %d \"%s\"\n", <line>, <pathname>

or
"# %d \"%s\" %s\n", <line>, <pathname>, <flags>

for each file processed as a result of a #include directive, unless no other output generated from that file is present in the output, where line is a line number, pathname is the pathname used to open the file, and flags is an implementation-defined string.

agadmin

2025-05-16 06:05

administrator   bugnote:0007185

Interpretation Proposed: 16 May 2025

Issue History

Date Modified Username Field Change
2025-05-10 02:36 Love4Boobies New Issue
2025-05-15 15:52 nick Note Added: 0007184
2025-05-15 15:53 nick Status New => Interpretation Required
2025-05-15 15:53 nick Resolution Open => Accepted As Marked
2025-05-15 15:53 nick Interp Status => ---
2025-05-15 15:53 nick Final Accepted Text => see 0001925:0007184
2025-05-15 15:54 nick Tag Attached: tc1-2024
2025-05-15 15:54 nick Interp Status --- => Pending
2025-05-16 06:05 agadmin Interp Status Pending => Proposed
2025-05-16 06:05 agadmin Note Added: 0007185