Debian Codegraph @

gcc/testsuite/gfortran.dg/analyzer/malloc-example.f90

raw
1 ! Example from GCC documentation
2 ! { dg-do compile }
3 ! { dg-additional-options "-fcray-pointer" }
4
5 program test_malloc
6 implicit none
7 integer i
8 real*8 x(*), z
9 pointer(ptr_x,x)
10
11 ptr_x = malloc(20*8)
12 do i = 1, 20
13 x(i) = sqrt(1.0d0 / i)
14 end do
15 z = 0
16 do i = 1, 20
17 z = z + x(i)
18 print *, z
19 end do
20 call free(ptr_x)
21 end program test_malloc