https://gcc.gnu.org/bugzilla/show_bug.cgi?id=111341
Bug ID: 111341 Summary: Elemental operator on zero-sized array seg-faults Product: gcc Version: 13.2.1 Status: UNCONFIRMED Severity: normal Priority: P3 Component: fortran Assignee: unassigned at gcc dot gnu.org Reporter: everythingfunctional at protonmail dot com Target Milestone: --- There were some scenarios in the real code for this that it doesn't segfault, but the following reproducer was able to do it reliably for me. fpm.toml name = "empty_elemental" version = "0.1.0" license = "license" author = "Brad Richardson" maintainer = "everythingfunctio...@protonmail.com" copyright = "Copyright 2023, Brad Richardson" [dependencies] strff = { git = "https://gitlab.com/everythingfunctional/strff.git", tag = "v4.0.0" } iso_varying_string = { git = "https://gitlab.com/everythingfunctional/iso_varying_string.git", tag = "v3.0.3" } app/main.f90 program main use iso_varying_string, only: varying_string, operator(//), put_line use strff, only: join implicit none call put_line(join("'" // empty() // "'", ",")) contains pure function empty() type(varying_string), allocatable :: empty(:) allocate(empty(0)) end function end program main For context, varying_string just has an allocatable deferred length character component, operator(//) is elemental, join concatenates an array of strings with the given separator between each, and put_line is basically just print for varying_string. So the above program should just print a single, zero length character.