Bug 70673 - [5/6/7 Regression] ICE with module containing functions with allocatable character scalars
Summary: [5/6/7 Regression] ICE with module containing functions with allocatable char...
Status: RESOLVED FIXED
Alias: None
Product: gcc
Classification: Unclassified
Component: fortran (show other bugs)
Version: 6.0
: P4 normal
Target Milestone: 5.5
Assignee: Not yet assigned to anyone
URL:
Keywords:
Depends on:
Blocks: 68241
  Show dependency treegraph
 
Reported: 2016-04-14 23:52 UTC by David Kinniburgh
Modified: 2016-10-24 11:20 UTC (History)
2 users (show)

See Also:
Host:
Target:
Build:
Known to work: 4.8.5, 4.9.3
Known to fail: 5.3.0, 6.0
Last reconfirmed: 2016-04-15 00:00:00


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description David Kinniburgh 2016-04-14 23:52:48 UTC
module m

contains

subroutine s
character(:), allocatable :: a1
a1 = a1
return

contains

integer function f1()
f1 = 0
end function f1
end subroutine s

     
integer function f2()
character(:), allocatable ::  a2 
f2 = 0
! this line causes a seg fault!
a2 = a2
end function f2

end module m


#####################

The above do-nothing construction gives an ICE. Difficult for me to know why but it is probably something to do with the allocatable character scalars. As far as I know, it is legal Fortran.

P.S. Thanks Paul, Dominique et al. for the recent push on the these things.

gcc version 6.0.0 20160410 (experimental) (GCC) :: mingw build from equation.com running on x86_w64.
Comment 1 David Kinniburgh 2016-04-15 00:06:48 UTC
Ah, maybe I reduced this too far as a1 and a2 are obviously uninitialized, but still...
Comment 2 David Kinniburgh 2016-04-15 00:47:50 UTC
Ah, maybe I reduced this too far as a1 and a2 are obviously uninitialized...

Is this better - it also produces an ICE?

module m

contains

subroutine s(in)
character(*), intent(in) :: in
character(:), allocatable :: a
a = in
a = a
return

contains

integer function f1()
f1 = 0
end function f1
end subroutine s

integer function f2(a)
character(*), intent(in) :: a
character(:), allocatable ::  in 
in = a
in = in
f2 = 0
end function f2

end module m
Comment 3 Dominique d'Humieres 2016-04-15 09:59:22 UTC
The tests compile with 4.8.5 and 4.9.3, but give an ICE with 5.3 and trunk (6.0). The change occurred between revisions r219174 (2015-01-04, OK) and r219318 (2015-01-07, ICE); r219193 (pr47674)?
Comment 4 David Kinniburgh 2016-04-15 13:34:56 UTC
It seems the problem usually arises when there is reassignment in one line, eg

character(:), allocatable: s, t
s = s(2:) ! or even s = s

whereas forcing the temporary 
t = s(2:)
s = t

seems to work. But it is not quite that simple as the above doesn't always fail. It requires other things to be happening too.
Comment 5 Paul Thomas 2016-06-13 07:48:56 UTC
Author: pault
Date: Mon Jun 13 07:48:25 2016
New Revision: 237358

URL: https://gcc.gnu.org/viewcvs?rev=237358&root=gcc&view=rev
Log:
2016-06-13  Paul Thomas  <pault@gcc.gnu.org>

	PR fortran/70673
	* frontend-passes.c (realloc_string_callback): Add a call to
	gfc_dep_compare_expr.

2016-06-13  Paul Thomas  <pault@gcc.gnu.org>

	PR fortran/70673
	* gfortran.dg/pr70673.f90: New test.

Added:
    trunk/gcc/testsuite/gfortran.dg/pr70673.f90
Modified:
    trunk/gcc/fortran/ChangeLog
    trunk/gcc/fortran/frontend-passes.c
    trunk/gcc/testsuite/ChangeLog
Comment 6 Paul Thomas 2016-06-27 19:18:53 UTC
Author: pault
Date: Mon Jun 27 19:18:21 2016
New Revision: 237802

URL: https://gcc.gnu.org/viewcvs?rev=237802&root=gcc&view=rev
Log:
2016-06-27  Paul Thomas  <pault@gcc.gnu.org>

	PR fortran/70673
	* frontend-passes.c (realloc_string_callback): Add a call to
	gfc_dep_compare_expr.

2016-06-27  Paul Thomas  <pault@gcc.gnu.org>

	PR fortran/70673
	* gfortran.dg/pr70673.f90: New test.

Added:
    branches/gcc-6-branch/gcc/testsuite/gfortran.dg/pr70673.f90
Modified:
    branches/gcc-6-branch/gcc/fortran/ChangeLog
    branches/gcc-6-branch/gcc/fortran/frontend-passes.c
    branches/gcc-6-branch/gcc/testsuite/ChangeLog
Comment 7 Paul Thomas 2016-06-27 20:55:28 UTC
Author: pault
Date: Mon Jun 27 20:54:56 2016
New Revision: 237804

URL: https://gcc.gnu.org/viewcvs?rev=237804&root=gcc&view=rev
Log:
2016-06-27  Paul Thomas  <pault@gcc.gnu.org>

	PR fortran/70673
	* frontend-passes.c (realloc_string_callback): Add a call to
	gfc_dep_compare_expr.

2016-06-27  Paul Thomas  <pault@gcc.gnu.org>

	PR fortran/70673
	* gfortran.dg/pr70673.f90: New test.

Added:
    branches/gcc-5-branch/gcc/testsuite/gfortran.dg/pr70673.f90
Modified:
    branches/gcc-5-branch/gcc/fortran/frontend-passes.c
Comment 8 Paul Thomas 2016-06-27 20:57:44 UTC
Author: pault
Date: Mon Jun 27 20:57:13 2016
New Revision: 237805

URL: https://gcc.gnu.org/viewcvs?rev=237805&root=gcc&view=rev
Log:
2016-06-27  Paul Thomas  <pault@gcc.gnu.org>

	PR fortran/70673
	* frontend-passes.c (realloc_string_callback): Add a call to
	gfc_dep_compare_expr.

2016-06-27  Paul Thomas  <pault@gcc.gnu.org>

	PR fortran/70673
	* gfortran.dg/pr70673.f90: New test.

Modified:
    branches/gcc-5-branch/gcc/fortran/ChangeLog
    branches/gcc-5-branch/gcc/testsuite/ChangeLog
Comment 9 Paul Thomas 2016-10-24 11:20:23 UTC
Closing rather belatedly!

Thanks for the report.

Paul