[Bug fortran/44582] gfortran generates wrong results due to wrong ABI in function with array return

dominiq at lps dot ens dot fr gcc-bugzilla@gcc.gnu.org
Sun Jun 20 20:10:00 GMT 2010



------- Comment #12 from dominiq at lps dot ens dot fr  2010-06-20 20:10 -------
With the patch in comment #10, the modified test for pr31538 from
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=31538#c5


 integer :: a(-4:1), b(0:4)
 b = 5
! a(-4:1) = b(0:4) ! Error: different shape for Array
!                  ! assignment at (1) on dimension 1 (6/5)
!
! gfortran: Array bound mismatch for dimension 1 of array 'f'
! NAG f95:  Rank 1 of array operand has extent 5 instead of 2
 i = 0
 a(i:1) = f(b)
contains
  function f(x)
    integer :: x(:),f(size(x))
    f = x
  end function
end

is no longer detected with -fckeck=bounds while the test

    program main
      integer, dimension (2) :: x
      x = (/ 1, 2 /)
      x = foo ()
      if (sum (x) .ne. 103) call abort
    contains
      function foo()
        integer, dimension (2) :: foo
        foo (1) = 100
        foo (2) = sum (x)
      end function
    end program main

pass.


-- 


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=44582



More information about the Gcc-bugs mailing list