File: pr92586.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 (61 lines) | stat: -rw-r--r-- 1,349 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
! { dg-do compile }
!
! Contributed by Emanuele Pagone  <epagone@email.it>
!
module foo_m
  implicit none

  type :: string
    character(len=:), allocatable :: s
  end type string

  type :: foo_t
    type(string), allocatable :: foo_s(:)
  contains
    procedure, public :: get_s
  end type foo_t

  type :: data_t
    integer                   :: n_foo_s
    type(foo_t), allocatable  :: foo(:)
  contains
    procedure, public :: data_get_foo_s
  end type data_t

contains

  function get_s(self)
    class(foo_t), intent(in)  :: self
    type(string)  :: get_s( size(self%foo_s) )
    get_s = self%foo_s
  end function get_s

  function data_get_foo_s(self, ith)
    class(data_t), intent(in) :: self
    integer, intent(in)       :: ith
    type(string)              :: data_get_foo_s(self%n_foo_s)

    data_get_foo_s = self%foo(ith)%get_s() ! The lhs was not dereferenced in a byref call.

  end function data_get_foo_s

end module foo_m


program bug_stringifor
  use foo_m
  implicit none

  type(data_t)              :: data
  type(string), allocatable :: bar(:)

  allocate( data%foo(1) )
  data%foo(1)%foo_s = [string("alpha"), string("bravo"), string("charlie"), &
                        string("delta"), string("foxtrot")]
  data%n_foo_s = 5

  bar = data%data_get_foo_s(1)

  print *, "bar = ", bar(1)%s

end program bug_stringifor