Note: This bug is displayed in read-only format because the product is no longer active in Red Hat Bugzilla.
RHEL Engineering is moving the tracking of its product development work on RHEL 6 through RHEL 9 to Red Hat Jira (issues.redhat.com). If you're a Red Hat customer, please continue to file support cases via the Red Hat customer portal. If you're not, please head to the "RHEL project" in Red Hat Jira and file new tickets here. Individual Bugzilla bugs in the statuses "NEW", "ASSIGNED", and "POST" are being migrated throughout September 2023. Bugs of Red Hat partners with an assigned Engineering Partner Manager (EPM) are migrated in late September as per pre-agreed dates. Bugs against components "kernel", "kernel-rt", and "kpatch" are only migrated if still in "NEW" or "ASSIGNED". If you cannot log in to RH Jira, please consult article #7032570. That failing, please send an e-mail to the RH Jira admins at rh-issues@redhat.com to troubleshoot your issue as a user management inquiry. The email creates a ServiceNow ticket with Red Hat. Individual Bugzilla bugs that are migrated will be moved to status "CLOSED", resolution "MIGRATED", and set with "MigratedToJIRA" in "Keywords". The link to the successor Jira issue will be found under "Links", have a little "two-footprint" icon next to it, and direct you to the "RHEL project" in Red Hat Jira (issue links are of type "https://issues.redhat.com/browse/RHEL-XXXX", where "X" is a digit). This same link will be available in a blue banner at the top of the page informing you that that bug has been migrated.

Bug 2045071

Summary: cpp stops when finding a missing include
Product: Red Hat Enterprise Linux 8 Reporter: Paulo Andrade <pandrade>
Component: gccAssignee: Marek Polacek <mpolacek>
gcc sub component: system-version QA Contact: qe-baseos-tools-bugs
Status: CLOSED NOTABUG Docs Contact:
Severity: medium    
Priority: unspecified CC: ahajkova, dmalcolm, fweimer, jakub, mpolacek, ohudlick, sipoyare
Version: 8.5Keywords: Triaged
Target Milestone: rcFlags: pm-rhel: mirror+
Target Release: ---   
Hardware: All   
OS: Linux   
Whiteboard:
Fixed In Version: Doc Type: If docs needed, set a value
Doc Text:
Story Points: ---
Clone Of: 2045069 Environment:
Last Closed: 2022-01-25 17:15:34 UTC Type: Bug
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: --- Target Upstream Version:
Embargoed:
Bug Depends On: 2045069    
Bug Blocks:    

Description Paulo Andrade 2022-01-25 14:48:36 UTC
+++ This bug was initially created as a clone of Bug #2045069 +++

Reproducer:

"""
$ cat test.c
#include <inc1.h>
#include <inc2.h>
#include <inc3.h>
main()
{
}

$ cat inc1.h
#include <limits.h>

$ cat inc2.h
#include <string.h>

$ cat inc3.h
#include <stdio.h>

$ cpp -I. -nostdinc test.c
# 1 "test.c"
# 1 "<built-in>"
# 1 "<command-line>"
# 1 "testprogram.c"
# 1 "./inc1.h" 1
In file included from test.c:1:0:
./inc1.h:1:19: fatal error: limits.h: No such file or directory
 #include <limits.h>
                   ^
compilation terminated.
"""

  On rhel6 it did list all missing includes, that is, would print something
like:

"""
# 1 "test.c"
# 1 "<built-in>"
# 1 "<command-line>"
# 1 "test.c"
# 1 "./inc1.h" 1
In file included from test.c:1:0:
./inc1.h:1:19: error: limits.h: No such file or directory [enabled by default]
 #include <limits.h>
                   ^
# 2 "test.c" 2
# 1 "./inc2.h" 1
In file included from test.c:2:0:
./inc2.h:1:19: error: string.h: No such file or directory [enabled by default]
 #include <string.h>
                   ^
# 3 "test.c" 2
# 1 "./inc3.h" 1
In file included from test.c:3:0:
./inc3.h:1:18: error: stdio.h: No such file or directory [enabled by default]
 #include <stdio.h>
                  ^
# 4 "testprogram.c" 2

main()
{
}
"""

  It appears the previous behavior should happen if one also pass
-Wno-fatal-errors to cpp command line.

  Note that on rhel7 and newer it prints "fatal error: ...", and on rhel6
it prints "error: ...".

  A possible workaround is to run as:

$ ( export DEPENDENCIES_OUTPUT=1; export SUNPRO_DEPENDENCIES=1; cpp -I. -nostdinc test.c )

what will cause cpp related flags to be set to follow a code path where
it will not cause a fatal error, but print "warning: ..." and list all
missing include files.

  The current behavior is likely the expected, as when not including
a file, any new error/warning messages are likely bogus as it could be
interpreted very differently if the missing include was loaded. But user
relies on previous behavior.

Comment 1 Marek Polacek 2022-01-25 17:15:34 UTC
Same as bug 2045069.