Segfault in TBP using shape intrinsic function

Janus Weil janus@gcc.gnu.org
Wed Mar 24 19:22:00 GMT 2010


Dear (unknown),

> thanks a lot for quickly fixing the pb with an optional argument in type-bound procedure!

it's my pleasure. Thanks for reporting it!

[Btw, maybe you could at least tell us your name. That may make it a
bit easier to have an actual conversation ...]


> I've encountered another issue, that I also reduced to the following test case.
> I am using gcc version 4.5.0 20100311 (experimental) (GCC)  on a x86_64 box.

I can reproduce the segfault that you're seeing. However, it is not
related at all to type-bound procedure or any sort of CLASS business
(as your test case might suggest). Here is another variant which lacks
all OOP goodies and still gives a segfault:

   implicit none

   type myobj
      real :: myarray(10)
   end type myobj

   real        :: array(10)
   type(myobj) :: obj

   call myfunc(obj,array)

contains

   subroutine myfunc(this, array)
      type(myobj) :: this
      real        :: array(:)
      write (*,*) 'shape bound', shape(this%myarray)
      write (*,*) 'shape input', shape(array)
      write (*,*) shape(array) /= shape(this%myarray) ! SEGFAULT
   end subroutine myfunc

end

Btw, this fails not only with trunk, but also with 4.4.1 (haven't
tried any earlier versions). Seems it is related to the deferred shape
of the dummy array, since the segfault disappears if I make it
explicit (as in "real :: array(10)").

I'm not exactly an expert on the array implementation of gfortran, and
the output of -fdump-tree-original is quite large, therefore I don't
see what's wrong right away.

In any case it's a bug in gfortran, and since you're starting to get
used to finding such creatures lately, why don't you go ahead and file
a PR in bugzilla? (http://gcc.gnu.org/bugzilla/)

Cheers,
Janus



More information about the Fortran mailing list