File: pr88688.f90

package info (click to toggle)
gcc-arm-none-eabi 15%3A14.2.rel1-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 1,099,328 kB
  • sloc: cpp: 3,627,108; ansic: 2,571,498; ada: 834,230; f90: 235,082; makefile: 79,231; asm: 74,984; xml: 51,692; exp: 39,736; sh: 33,298; objc: 15,629; python: 15,069; fortran: 14,429; pascal: 7,003; awk: 5,070; perl: 3,106; ml: 285; lisp: 253; lex: 204; haskell: 135
file content (62 lines) | stat: -rw-r--r-- 1,231 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
! { dg-do run }
!
! Contributed by Thomas Fanning <thfanning@gmail.com>
!
!
module mod

    type test
        class(*), pointer :: ptr
    contains
        procedure :: setref
    end type

contains

    subroutine setref(my,ip)
    implicit none
        class(test) :: my
        integer, pointer :: ip
        my%ptr => ip
    end subroutine

    subroutine set7(ptr)
    implicit none
        class(*), pointer :: ptr
        select type (ptr)
            type is (integer)
                ptr = 7
        end select
    end subroutine

end module
!---------------------------------------

!---------------------------------------
program bug
use mod
implicit none

    integer, pointer :: i, j
    type(test) :: tp
    class(*), pointer :: lp

    allocate(i,j)
    i = 3; j = 4

    call tp%setref(i)
    select type (ap => tp%ptr)
        class default
            call tp%setref(j)
            lp => ap
            call set7(lp)
    end select

! gfortran used to give i=3 and j=7 because the associate name was not pointing
! to the target of tp%ptr as required by F2018:19.5.1.6 but, rather, to the
! selector itself.
    if (i .ne. 7) stop 1
    if (j .ne. 4) stop 2

end program
!---------------------------------------