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 1369183

Summary: gfortran compiler crash
Product: Red Hat Enterprise Linux 7 Reporter: Paulo Andrade <pandrade>
Component: gccAssignee: Jakub Jelinek <jakub>
Status: CLOSED ERRATA QA Contact: Michael Petlan <mpetlan>
Severity: medium Docs Contact:
Priority: medium    
Version: 7.2CC: cww, law, mcermak, mnewsome, mpetlan, mpolacek, tobias.henle
Target Milestone: rc   
Target Release: ---   
Hardware: All   
OS: Linux   
Whiteboard:
Fixed In Version: gcc-4.8.5-12.el7 Doc Type: If docs needed, set a value
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2017-08-01 22:35:59 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:    
Bug Blocks: 1298243, 1390370    
Attachments:
Description Flags
reproducer.tar none

Description Paulo Andrade 2016-08-22 15:28:36 UTC
Created attachment 1192960 [details]
reproducer.tar

This is a simple crash on apparently valid code. The
crash happens due to no fields declared to a sequence
type; adding a field or removing the sequence attribute
prevents the crash.

  A simple patch could be to add:

          if (dt1 == dt2)
            return 1;
          if (!dt1 || !dt2)
            return 0;

to gfc_compare_derived_types before the for loop:

389	int
390	gfc_compare_derived_types (gfc_symbol *derived1, gfc_symbol *derived2)
[...]
421	  dt1 = derived1->components;
422	  dt2 = derived2->components;
423	
424	  /* Since subtypes of SEQUENCE types must be SEQUENCE types as well, a
425	     simple test can speed things up.  Otherwise, lots of things have to
426	     match.  */
427	  for (;;)
428	    {
429	      if (strcmp (dt1->name, dt2->name) != 0)
430		return 0;
431	
432	      if (dt1->attr.access != dt2->attr.access)
433		return 0;

or a slightly less readable variant:

          if (!dt1 || !dt2)
              return dt1 == dt2;

  Simple reproducer derived from user issue attached.

Comment 1 Marek Polacek 2016-08-22 15:57:13 UTC
The ICE was fixed in <https://gcc.gnu.org/r235999>.  But since that revision I get:

$ ./f951 -quiet t.f90
t.f90:6:12:

    call sub(tst)
            1
Error: Type mismatch in argument ‘test’ at (1); passed TYPE(test_t) to TYPE(test_t)

You said "apparently valid code", but did you really mean "valid"?  I don't know Fortran to gauge whether this is or isn't valid.

In any case, the revision is pretty recent and doesn't seem to be backportable.

Comment 2 Paulo Andrade 2016-08-22 16:15:51 UTC
  I said apparently valid code because the specification
appears to not tell about empty types:

TYPE [[ , access specification ] :: ] type name
  [ PRIVATE ]
  [ SEQUENCE ]
  [ type specification [[ , POINTER ] :: ] component specification list ]
  ...
END TYPE [ type name ]

  The type mismatch error is expected. The user just
believes that the ICE should not happen.

Comment 3 Marek Polacek 2016-08-22 16:22:15 UTC
Sure, the ICE is definitely a bug, but if the type mismatch error is expected, then this would be ICE-on-invalid, and such bugs have a rather low priority.

Comment 4 Paulo Andrade 2016-08-22 17:05:31 UTC
  I just tested on rawhide, with this minor change,
to make the types compatible:

mod.f90:
-    integer(4) type
+!   integer(4) type

and test.sh (to avoid link failure):

- gfortran t.f90
+ gfortran -c t.f90

and it compiles and generates .o files.

Comment 10 Michael Petlan 2017-05-31 14:09:46 UTC
The related test passes on all architectures with gcc-4.8.5-14.el7.
VERIFIED.

Comment 11 errata-xmlrpc 2017-08-01 22:35:59 UTC
Since the problem described in this bug report should be
resolved in a recent advisory, it has been closed with a
resolution of ERRATA.

For information on the advisory, and where to find the updated
files, follow the link below.

If the solution does not work for you, open a new bug report.

https://access.redhat.com/errata/RHBA-2017:2094