Bug 42851 - ICE (segfault) at gfc_trans_pointer_assignment for subpointer
Summary: ICE (segfault) at gfc_trans_pointer_assignment for subpointer
Status: RESOLVED DUPLICATE of bug 34640
Alias: None
Product: gcc
Classification: Unclassified
Component: fortran (show other bugs)
Version: 4.5.0
: P3 normal
Target Milestone: ---
Assignee: Not yet assigned to anyone
URL:
Keywords: ice-on-valid-code
Depends on:
Blocks: 32834 42361 39304 43091
  Show dependency treegraph
 
Reported: 2010-01-23 17:40 UTC by Tobias Burnus
Modified: 2010-05-18 22:22 UTC (History)
4 users (show)

See Also:
Host:
Target:
Build:
Known to work:
Known to fail: 4.4.3 4.5.1 4.6.0
Last reconfirmed: 2010-02-12 05:07:35


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Tobias Burnus 2010-01-23 17:40:34 UTC
Found while looking again as PR 39304. The following program causes an ICE. It might well be only fixable with the new array descriptor.

The program works with 4.1 and 4.2 (which might well be only by chance) but fails with 4.3/4.4/4.5 with:

test.f90: In function 'func':
test.f90:7:0: internal compiler error: Segmentation fault

Program received signal SIGSEGV, Segmentation fault.
0x000000000055d935 in gfc_trans_pointer_assignment (expr1=0x137b4e0, expr2=0x137b970) at /home/tob/projects/gcc/gcc/fortran/trans-expr.c:4676
4676                  gfc_add_modify (&lse.post, GFC_DECL_SPAN(decl), tmp);


module m
  implicit none
  type t
    real :: a(3)
  end type t
contains
  function func(x,i)
    type(t), target :: x(:)
    integer :: i
    real, dimension(:), pointer :: func
    func => x%a(i)
  end function func
end module m

use m
type(t) :: mt(3)
real :: res(3)
mt = t(1.0)
res = matmul(func(mt,1), reshape( (/1,2,3,4,5,6,7,8,9/), (/3,3 /) ))
if (res(1) /= 6.0 .and. res(2) /= 15.0 .and. res(3) /= 24.0) then
  print *, res
  stop 'error'
end if
end
Comment 1 Jerry DeLisle 2010-02-12 05:07:35 UTC
Might as well confirm this one.
Comment 2 Daniel Franke 2010-05-18 22:09:57 UTC
Reduced testcase:

  type t
    real :: a(3)
  end type t
contains
  function func(x)
    type(t), target :: x(:)
    real, dimension(:), pointer :: func
    func => x%a(1)
  end function func
end
Comment 3 Daniel Franke 2010-05-18 22:22:19 UTC
Roughly the same testcase, same backtrace.

*** This bug has been marked as a duplicate of 34640 ***