fortran-compiler-tests icon indicating copy to clipboard operation
fortran-compiler-tests copied to clipboard

Reproducer for gfortran bug 98141

Open dhnza opened this issue 4 years ago • 5 comments

This PR adds a minimal reproducer for gfortran bug 98141.

dhnza avatar Dec 04 '20 13:12 dhnza

Looking at your example and drawing on past experience, I suspected that the problem was with the sourced allocation statement, and that does appear the case (although there may be multiple compiler bugs here). Here's a minimal example that triggers a segfault:

class(*), allocatable :: a, b
allocate(character(len=0)::a)
allocate(b, source=a)
end

nncarlson avatar Dec 04 '20 14:12 nncarlson

Looking at your example and drawing on past experience, I suspected that the problem was with the sourced allocation statement, and that does appear the case (although there may be multiple compiler bugs here). Here's a minimal example that triggers a segfault:

class(*), allocatable :: a, b
allocate(character(len=0)::a)
allocate(b, source=a)
end

Nice! Strangely, this doesn't work

program foo
  class(*), allocatable :: a, b
  allocate(a, source='')  !! No problem
  allocate(b, source=a)  !! Segfaults                                                                                                                                                                                     
end program

I'll add these examples to the bug report.

dhnza avatar Dec 04 '20 15:12 dhnza

I'll also pare down the example in this MR and add the new examples.

dhnza avatar Dec 04 '20 15:12 dhnza

This does work, however:

program foo
  class(*), allocatable :: a
  character(len=0) :: s
  allocate(a, source=s)
end program

dhnza avatar Dec 04 '20 16:12 dhnza

This latest version has the minimal examples we found.

dhnza avatar Dec 04 '20 16:12 dhnza