Memory allocation failed because of parenthesis
Janus Weil
janus@gcc.gnu.org
Tue Dec 23 20:53:00 GMT 2014
Hi Pat,
> I want your thought concerning a parenthesis bug for the following code. The expression (a+b) works well, while ((a)+(b)) triggers a memory allocation issue.
> And its works fine, if there is no allocatable components in the type. I guess it is a pointer pass to the subroutine that is wrong or a parser issue ? but I wasn't sure what title
> to give to the bug report in that case. I got this behavior with gfortran 4.9.2, and the code runs fine with intel compiler.
thanks for reporting this. I can reproduce the segfault with various
versions of gfortran (4.7, 4.8, 4.9 and trunk) and I think it's a
compiler bug. Also I could reduce your test case a bit, getting rid of
some code that is not required to reproduce the problem (see below).
-fdump-tree-original should show where things go wrong in the
generated code, but I could not see the problem at first sight. Could
you please file a PR in bugzilla?
Thanks,
Janus
module num
type :: my_integer
real, allocatable :: x(:)
contains
procedure :: ass
generic :: assignment(=) => ass
end type
contains
subroutine ass(a,b)
class(my_integer), intent(out) :: a
class(my_integer), intent(in) :: b
select type (b)
type is (my_integer)
allocate(a%x(size(b%x)))
a%x = b%x
end select
print *,'called ass'
end subroutine
end module
program main
use num
type(my_integer) :: a, c
a=my_integer([1])
write (*,*) "C: ",c%x
c = a
write (*,*) "C: ",c%x
c = (a)
write (*,*) "C: ",c%x
end
More information about the Fortran
mailing list