3 ! Test the fix for PR80931, which was nearly fix by the patch for PR87151.
4 ! However, the 'span' for 'temp' was not being set and so a segfault
5 ! occurred in the assignment at line 39.
7 ! Contributed by Tiziano Mueller <dev-zero@gentoo.org>
9 module input_section_types
11 character(len=:), allocatable :: keywords_(:)
14 procedure, pass :: add_keyword
23 type(section) function constructor ()
24 allocate (character(len=255) :: constructor%keywords_(0))
27 subroutine add_keyword (this, name)
28 class(section), intent(inout) :: this
29 character(*), intent(in) :: name
30 character(len=:), allocatable :: temp(:)
34 n_elements = size (this%keywords_)
35 allocate (character(len=255) :: temp(n_elements+1))
36 temp(:n_elements) = this%keywords_
37 call move_alloc (temp, this%keywords_)
39 this%keywords_(n_elements+1) = name
43 use input_section_types
45 character(*), parameter :: hello = "Hello World"
46 character(*), parameter :: bye = "Goodbye World"
50 call s%add_keyword (hello)
51 if (len (s%keywords_) .ne. 255) stop 1
52 if (size (s%keywords_, 1) .ne. 1) stop 2
53 if (trim (s%keywords_(1)) .ne. hello) stop 3
55 call s%add_keyword (bye)
56 if (len (s%keywords_) .ne. 255) stop 4
57 if (size (s%keywords_, 1) .ne. 2) stop 5
58 if (trim (s%keywords_(1)) .ne. hello) stop 6
59 if (trim (s%keywords_(2)) .ne. bye) stop 7