https://gcc.gnu.org/bugzilla/show_bug.cgi?id=120711

            Bug ID: 120711
           Summary: Growing arrays segfaults when compiling with
                    -fcoarray=single
           Product: gcc
           Version: 15.1.1
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: fortran
          Assignee: unassigned at gcc dot gnu.org
          Reporter: albert at tugraz dot at
  Target Milestone: ---

Created attachment 61665
  --> https://gcc.gnu.org/bugzilla/attachment.cgi?id=61665&action=edit
Minimal reproducible example

gcc version 15.1.1 20250425 (GCC) on Arch Linux

This issue appears on Linux in both 15.1.0 and 15.1.1, but apparently not on
MacOS 15.1.0 homebrew version. Since fpm uses -fcoarray=single as a default
argument, it breaks various codes. The issue appears when growing an array and
call a factory/constructor directly inside, i.e.

list = [list, new_string("Hello!")]

In contrast,

str = new_string("Hello!")
list = [list, str]

seems to work fine. An example is attached.


$ gfortran -g -fcoarray=single grow_type_array.f90 && ./a.out

Program received signal SIGSEGV: Segmentation fault - invalid memory reference.

Backtrace for this error:
#0  0x14d8846a46a7 in ???
#1  0x14d8846a3675 in ???
#2  0x14d88423e6ef in ???
#3  0x14d884299cfe in ???
#4  0x4028dd in grow_type_array
        at grow_type_array.f90:19
#5  0x402951 in main
        at grow_type_array.f90:19
Segmentation fault (core dumped)

$ gfortran -v
Using built-in specs.
COLLECT_GCC=gfortran
COLLECT_LTO_WRAPPER=/usr/lib/gcc/x86_64-pc-linux-gnu/15.1.1/lto-wrapper
Target: x86_64-pc-linux-gnu
Configured with: /build/gcc/src/gcc/configure
--enable-languages=ada,c,c++,d,fortran,go,lto,m2,objc,obj-c++,rust,cobol
--enable-bootstrap --prefix=/usr --libdir=/usr/lib --libexecdir=/usr/lib
--mandir=/usr/share/man --infodir=/usr/share/info
--with-bugurl=https://gitlab.archlinux.org/archlinux/packaging/packages/gcc/-/issues
--with-build-config=bootstrap-lto --with-linker-hash-style=gnu
--with-system-zlib --enable-__cxa_atexit --enable-cet=auto
--enable-checking=release --enable-clocale=gnu --enable-default-pie
--enable-default-ssp --enable-gnu-indirect-function --enable-gnu-unique-object
--enable-libstdcxx-backtrace --enable-link-serialization=1
--enable-linker-build-id --enable-lto --enable-multilib --enable-plugin
--enable-shared --enable-threads=posix --disable-libssp --disable-libstdcxx-pch
--disable-werror
Thread model: posix
Supported LTO compression algorithms: zlib zstd
gcc version 15.1.1 20250425 (GCC)

Reply via email to