3 ! Test the fix for PR96495 - segfaults at runtime at locations below.
5 ! Contributed by Paul Luckner <paul.luckner@rwth-aachen.de>
12 integer, allocatable
:: j(:)
15 interface operator(.unary
.)
16 module procedure neg_foo
19 interface operator(.binary
.)
20 module procedure foo_sub_foo
23 interface operator(.binaryElemental
.)
24 module procedure foo_add_foo
29 elemental
function foo_add_foo(f
, g
) result(h
)
30 !! an example for an elemental binary operator
31 type(foo
), intent(in
) :: f
, g
34 allocate (h
%j(size(f
%j
)), source
= f
%j
+g
%j
)
37 elemental
function foo_sub_foo(f
, g
) result(h
)
38 !! an example for an elemental binary operator
39 type(foo
), intent(in
) :: f
, g
42 allocate (h
%j(size(f
%j
)), source
= f
%j
-3*g
%j
)
45 pure
function neg_foo(f
) result(g
)
46 !! an example for a unary operator
47 type(foo
), intent(in
) :: f
50 allocate (g
%j(size(f
%j
)), source
= -f
%j
)
67 if (any (g(2)%j
.ne
. [2, 3, 4])) stop 1
69 g
= g
.binaryElemental
. (f
.binary
. f
) ! threw "Segmentation fault"
70 if (any (g(2)%j
.ne
. [-2,-3,-4])) stop 2
72 g
= g
.binaryElemental
. ( .unary
. f
) ! threw "Segmentation fault"
73 if (any (g(2)%j
.ne
. [-4,-6,-8])) stop 3