! { dg-do compile }
|
! { dg-do compile }
|
! Test the patch for PR30084 in which the reference to SIZE
|
! Test the patch for PR30084 in which the reference to SIZE
|
! in function diag caused a segfault in module.c.
|
! in function diag caused a segfault in module.c.
|
!
|
!
|
! Contributed by Troban Trumsko
|
! Contributed by Troban Trumsko
|
! and reduced by Steve Kargl
|
! and reduced by Steve Kargl
|
!
|
!
|
module tao_random_numbers
|
module tao_random_numbers
|
integer, dimension(10) :: s_buffer
|
integer, dimension(10) :: s_buffer
|
integer :: s_last = size (s_buffer)
|
integer :: s_last = size (s_buffer)
|
end module tao_random_numbers
|
end module tao_random_numbers
|
|
|
module linalg
|
module linalg
|
contains
|
contains
|
function diag (a) result (d)
|
function diag (a) result (d)
|
real, dimension(:,:), intent(in) :: a
|
real, dimension(:,:), intent(in) :: a
|
real, dimension(min(size(a,dim=1),size(a,dim=2))) :: d
|
real, dimension(min(size(a,dim=1),size(a,dim=2))) :: d
|
integer :: i
|
integer :: i
|
do i = 1, min(size(a, dim = 1), size(a, dim = 2))
|
do i = 1, min(size(a, dim = 1), size(a, dim = 2))
|
d(i) = a(i,i)
|
d(i) = a(i,i)
|
end do
|
end do
|
end function diag
|
end function diag
|
end module linalg
|
end module linalg
|
|
|
module vamp_rest
|
module vamp_rest
|
use tao_random_numbers
|
use tao_random_numbers
|
use linalg
|
use linalg
|
end module vamp_rest
|
end module vamp_rest
|
|
|
use vamp_rest
|
use vamp_rest
|
real :: x(2, 2) = reshape ([1.,2.,3.,4.], [2,2])
|
real :: x(2, 2) = reshape ([1.,2.,3.,4.], [2,2])
|
print *, s_last
|
print *, s_last
|
print *, diag (x)
|
print *, diag (x)
|
end
|
end
|
! { dg-final { cleanup-modules "tao_random_numbers linalg vamp_rest" } }
|
! { dg-final { cleanup-modules "tao_random_numbers linalg vamp_rest" } }
|
|
|