https://gcc.gnu.org/bugzilla/show_bug.cgi?id=64397
Bug ID: 64397
Summary: memory allocation failed with parenthesis
Product: gcc
Version: 4.9.2
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: fortran
Assignee: unassigned at gcc dot gnu.org
Reporter: patnel97269-gfortran at yahoo dot fr
Hi all,
I want to report a bug which i describe orignially here,
https://gcc.gnu.org/ml/fortran/2014-12/msg00117.html .
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.
Janus Weil worked out a reduce test case below, and can reproduce the segfault
with various versions of gfortran (4.7, 4.8, 4.9 and trunk) :
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
Thanks
Pat.