This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: [Patch, fortran, PR44672, v6] [F08] ALLOCATE with SOURCE and no array-spec


Hi Andre,

just a couple of remarks.

You are adding significant new code to an existing
test case, allocate_with_source_3.f90.  As discussed
previously, it would be better to put the new code
into an extra test case.

The following test case segfaults with your patch
with an "invalid free":

module foo
contains
  integer function f()
    f = 2
  end function f
end module foo
program main
  use foo
  integer :: n
  n = 42
  block
    real, dimension(0:n) :: a
    real, dimension(:), allocatable :: c
    call random_number(a)
    allocate(c,source=a(:f()))
  end block
end program main

You could also add

    n = n - 1
    allocate(c,source=a)
    if (size(a,1) /= size(c,1)) call abort

to the test case above to make sure that changing a variable
that was used to declare an array bound does not lead to wrong
code.

Regards

	Thomas


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]