https://gcc.gnu.org/bugzilla/show_bug.cgi?id=110288
Bug ID: 110288
Summary: [11/12/13] Regression: segfault in findloc with
allocatable array of allocatable characters
Product: gcc
Version: 11.0
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: fortran
Assignee: unassigned at gcc dot gnu.org
Reporter: zed.three at gmail dot com
Target Milestone: ---
Created attachment 55350
--> https://gcc.gnu.org/bugzilla/attachment.cgi?id=55350&action=edit
Minimal example source code
The following program crashes with a segfault "invalid memory reference" inside
`findloc`:
program test
character(len=:), allocatable, dimension(:) :: array
array = ["bb", "bb"]
print*, findloc(array, "aa", dim=1)
end program
Compiler Explorer example: https://godbolt.org/z/Evrnose5o
The same program works in gfortran 10.4, crashes in 11+, including trunk (GNU
Fortran
(Compiler-Explorer-Build-gcc-7ff793415f55fa9a92f348fecb8c75ac8acc8b87-binutils-2.40)
14.0.0 20230616 (experimental)).
A minimum of two elements in the array are required, and it must be
allocatable, but it doesn't matter if the element is in `array` or not.