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

            Bug ID: 110995
           Summary: segfault for function in declaration of module
                    function
           Product: gcc
           Version: unknown
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: fortran
          Assignee: unassigned at gcc dot gnu.org
          Reporter: thod_ at gmx dot de
  Target Milestone: ---

Created attachment 55724
  --> https://gcc.gnu.org/bugzilla/attachment.cgi?id=55724&action=edit
Test code

In this example (which looks a bit strange in its minimalistic form), gfortran
(in all versions that I have access to, i.e. on SUSE 7.5.0, 12.3.0, 13.2.1)
fails with segfault. The example works with ifort and if the function is
charArrToString_ is used in the main program instead of charArrToString in the
module - or alternatively
  character(len = lenCharArr(data)) :: charArrToString
is changed to
  character(len = size(data)) :: charArrToString
in the module function charArrToString.

Steps to reproduce (str.f90 attached):
$ gfortran str.f90

Output:
str.f90:38:48:

   38 |   write(*,*) "write module-", charArrToString(c), "-"
      |                                                1
interner Compiler-Fehler: Speicherzugriffsfehler
0x10f0b1a internal_error(char const*, ...)
        ???:0
0x11d4bb7 size_binop_loc(unsigned int, tree_code, tree_node*, tree_node*)
        ???:0
0x12371ca get_inner_reference(tree_node*, poly_int_pod<1u, long>*,
poly_int_pod<1u, long>*, tree_node**, machine_mode*, int*, int*, int*)
        ???:0
0x11dfcbe fold_unary_loc(unsigned int, tree_code, tree_node*, tree_node*)
        ???:0
0x11df5ac fold_build1_loc(unsigned int, tree_code, tree_node*, tree_node*)
        ???:0
0x19c436f convert(tree_node*, tree_node*)
        ???:0
0x19e045c gfc_get_dataptr_offset(stmtblock_t*, tree_node*, tree_node*,
tree_node*, bool, gfc_expr*)
        ???:0
0x19ea313 gfc_conv_expr_descriptor(gfc_se*, gfc_expr*)
        ???:0
0x19f3ab5 gfc_conv_array_parameter(gfc_se*, gfc_expr*, bool, gfc_symbol const*,
char const*, tree_node**)
        ???:0
0x1a240e0 gfc_conv_procedure_call(gfc_se*, gfc_symbol*, gfc_actual_arglist*,
gfc_expr*, vec<tree_node*, va_gc, vl_embed>*)
        ???:0
0x1a1217e gfc_apply_interface_mapping(gfc_interface_mapping*, gfc_se*,
gfc_expr*)
        ???:0
0x1a26696 gfc_conv_procedure_call(gfc_se*, gfc_symbol*, gfc_actual_arglist*,
gfc_expr*, vec<tree_node*, va_gc, vl_embed>*)
        ???:0
0x1a4940a gfc_conv_expr_reference(gfc_se*, gfc_expr*)
        ???:0
0x1a63c99 gfc_trans_transfer(gfc_code*)
        ???:0
0x1a1c127 gfc_generate_function_code(gfc_namespace*)
        ???:0
0x1986404 gfc_parse_file()
        ???:0

Version info:
COLLECT_GCC=gfortran
COLLECT_LTO_WRAPPER=/usr/lib64/gcc/x86_64-suse-linux/13/lto-wrapper
OFFLOAD_TARGET_NAMES=nvptx-none:amdgcn-amdhsa
OFFLOAD_TARGET_DEFAULT=1
Ziel: x86_64-suse-linux
Konfiguriert mit: ../configure CFLAGS=' -O2 -funwind-tables
-fasynchronous-unwind-tables -fstack-clash-protection -Werror=return-type -g'
CXXFLAGS=' -O2 -funwind-tables -fasynchronous-unwind-tables
-fstack-clash-protection -Werror=return-type -g' XCFLAGS=' -O2 -funwind-tables
-fasynchronous-unwind-tables -fstack-clash-protection -Werror=return-type -g'
TCFLAGS=' -O2 -funwind-tables -fasynchronous-unwind-tables
-fstack-clash-protection -Werror=return-type -g' GDCFLAGS=' -O2 -funwind-tables
-fasynchronous-unwind-tables -fstack-clash-protection -g' --prefix=/usr
--infodir=/usr/share/info --mandir=/usr/share/man --libdir=/usr/lib64
--libexecdir=/usr/lib64
--enable-languages=c,c++,objc,fortran,obj-c++,ada,go,d,jit,m2
--enable-offload-targets=nvptx-none,amdgcn-amdhsa, --enable-offload-defaulted
--without-cuda-driver --enable-host-shared --enable-checking=release
--disable-werror --with-gxx-include-dir=/usr/include/c++/13
--with-libstdcxx-zoneinfo=/usr/share/zoneinfo --enable-ssp --disable-libssp
--disable-libvtv --enable-cet=auto --disable-libcc1 --enable-plugin
--with-bugurl=https://bugs.opensuse.org/ --with-pkgversion='SUSE Linux'
--with-slibdir=/lib64 --with-system-zlib --enable-libstdcxx-allocator=new
--disable-libstdcxx-pch --enable-libphobos
--enable-version-specific-runtime-libs --with-gcc-major-version-only
--enable-linker-build-id --enable-linux-futex --enable-gnu-indirect-function
--program-suffix=-13 --without-system-libunwind --enable-multilib
--with-arch-32=x86-64 --with-tune=generic
--with-build-config=bootstrap-lto-lean --enable-link-serialization
--build=x86_64-suse-linux --host=x86_64-suse-linux
Thread-Modell: posix
Unterstützte LTO-Kompressionsalgorithmen: zlib zstd
gcc-Version 13.2.1 20230803 [revision cc279d6c64562f05019e1d12d0d825f9391b5553]
(SUSE Linux)

Reply via email to