https://gcc.gnu.org/bugzilla/show_bug.cgi?id=61775

lkrupp at gcc dot gnu.org changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |lkrupp at gcc dot gnu.org

--- Comment #6 from lkrupp at gcc dot gnu.org ---
I started looking at this until I read all of the comments and realized that
someone had already come up with a patch, and one that is probably better and
certainly simpler than whatever I would have done.

It might be worth noting that the problem seems to come up when an array is
passed to an intrinsic function that returns a scalar when its argument is a
scalar and that returns an array when it's passed an array.  In the sample
program in the description, the intrinsic function is integer to real
conversion.  The following sample program reproduces that problem with a simple
array instead of an implied do loop, and also with the square root function. 
Compiling this with -fbounds-check makes the program fail on the assignment
statement:

program assign_allocatable
implicit none

  call s_int_real_cvt
  call s_sqrt

contains

  subroutine s_int_real_cvt
  implicit none
  integer, parameter :: r(3) = [101, 102, 103]
  real, allocatable :: k(:)

  k = r

  if (any(k /= r)) call abort

  return
  end subroutine

  subroutine s_sqrt
  implicit none
  real, parameter :: r(5) = [1, 4, 9, 16, 25]
  real, allocatable :: a(:)

  a = sqrt(r)

  if (any(a /= [1, 2, 3, 4, 5])) call abort

  return
  end subroutine

end program

Array-value intrinsics like TRANSFER and PACK don't seem to trigger this
problem.

Reply via email to