Debian Codegraph @

gcc/testsuite/gfortran.dg/alloc_comp_constructor_4.f90

raw
1 ! { dg-do run }
2 ! Tests the fix for PR32795, which was primarily about memory leakage is
3 ! certain combinations of alloctable components and constructors. This test
4 ! which appears in comment #2 of the PR has the advantage of a wrong
5 ! numeric result which is symptomatic.
6 !
7 ! Contributed by Tobias Burnus <[email protected]>
8 !
9 type :: a
10 integer, allocatable :: i(:)
11 end type a
12 type(a) :: x, y
13 x = a ([1, 2, 3])
14 y = a (x%i(:)) ! used to cause a memory leak and wrong result
15 if (any (x%i .ne. [1, 2, 3])) STOP 1
16 end