Bug 40848 - [4.5 Regression] ICE with alternate returns
[4.5 Regression] ICE with alternate returns
Status: RESOLVED FIXED
Product: gcc
Classification: Unclassified
Component: fortran
4.5.0
: P3 normal
: 4.5.0
Assigned To: janus
: ice-on-valid-code
Depends on:
Blocks: 32834
  Show dependency treegraph
 
Reported: 2009-07-24 17:41 UTC by Joost VandeVondele
Modified: 2009-07-28 13:31 UTC (History)
2 users (show)

See Also:
Host:
Target:
Build:
Known to work: 4.4.1
Known to fail: 4.5.0
Last reconfirmed: 2009-07-25 14:17:20


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Joost VandeVondele 2009-07-24 17:41:33 UTC
MODULE TT
INTERFACE M
 MODULE PROCEDURE M1,M2
END INTERFACE
CONTAINS
 SUBROUTINE M1(I,*)
   INTEGER :: I
   RETURN 1
 END SUBROUTINE
 SUBROUTINE M2(I,J)
   INTEGER :: I,J
 END SUBROUTINE
END MODULE

USE TT
  CALL M(1,*2)
  write(6,*) "Hi"
2 CONTINUE
END
Comment 1 Tobias Burnus 2009-07-24 18:41:19 UTC
Confirmed. Janus - I think it could be do to your 4.5 argument checking patches.

==8885== Invalid read of size 8
==8885==    at 0x4C2050: compare_type_rank (interface.c:474)
==8885==    by 0x4C20C4: generic_correspondence (interface.c:905)
==8885==    by 0x4C28B9: gfc_compare_interfaces (interface.c:986)
==8885==  Address 0x98 is not stack'd, malloc'd or (recently) free'd


At a glance, the code looks innocent. interface.c:474 is the last line of:

compare_type_rank (gfc_symbol *s1, gfc_symbol *s2)
{
  int r1, r2;
  r1 = (s1->as != NULL) ? s1->as->rank : 0;
  r2 = (s2->as != NULL) ? s2->as->rank : 0;

The call is:
      if (f2 != NULL && compare_type_rank (f1->sym, f2->sym))
Seemingly f2->sym is NULL.
Comment 2 janus 2009-07-25 14:17:19 UTC
(In reply to comment #1)
> Confirmed. Janus - I think it could be do to your 4.5 argument checking
> patches.

Jep. r148519 to be precise. Will fix ...

Comment 3 janus 2009-07-27 18:26:49 UTC
Subject: Bug 40848

Author: janus
Date: Mon Jul 27 18:26:34 2009
New Revision: 150134

URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=150134
Log:
2009-07-27  Janus Weil  <janus@gcc.gnu.org>

	PR fortran/40848
	* interface.c (gfc_compare_interfaces): Call 'count_types_test' before
	'generic_correspondence', and only if checking a generic interface.


2009-07-27  Janus Weil  <janus@gcc.gnu.org>

	PR fortran/40848
	* gfortran.dg/altreturn_7.f90: New.


Added:
    trunk/gcc/testsuite/gfortran.dg/altreturn_7.f90
Modified:
    trunk/gcc/fortran/ChangeLog
    trunk/gcc/fortran/interface.c
    trunk/gcc/testsuite/ChangeLog

Comment 4 janus 2009-07-28 13:31:36 UTC
Fixed with r150134. Closing.
Comment 5 hjl@gcc.gnu.org 2009-07-28 16:51:47 UTC
Subject: Bug 40848

Author: hjl
Date: Tue Jul 28 16:51:19 2009
New Revision: 150169

URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=150169
Log:
2009-07-28  H.J. Lu  <hongjiu.lu@intel.com>

	Backport from mainline:
	2009-07-27  Janus Weil  <janus@gcc.gnu.org>

	PR fortran/40848
	* gfortran.dg/altreturn_7.f90: New.

	2009-07-27  Simon Baldwin  <simonb@google.com>

	PR testsuite/40829
	* gcc.dg/vect/no-scevccp-noreassoc-outer-2.c: Extended array 'a'
	so that indexing no longer runs off array end.

	2009-07-24  Janus Weil  <janus@gcc.gnu.org>

	PR fortran/40822
	* gfortran.dg/char_length_16.f90: New.

Added:
    branches/gcc-4_4-branch/gcc/testsuite/gfortran.dg/altreturn_7.f90
      - copied unchanged from r150168, trunk/gcc/testsuite/gfortran.dg/altreturn_7.f90
    branches/gcc-4_4-branch/gcc/testsuite/gfortran.dg/char_length_16.f90
      - copied unchanged from r150168, trunk/gcc/testsuite/gfortran.dg/char_length_16.f90
Modified:
    branches/gcc-4_4-branch/gcc/testsuite/ChangeLog
    branches/gcc-4_4-branch/gcc/testsuite/gcc.dg/vect/no-scevccp-noreassoc-outer-2.c