public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug fortran/110995] New: segfault for function in declaration of module function
@ 2023-08-11 15:18 thod_ at gmx dot de
  2023-08-14 19:47 ` [Bug fortran/110995] " anlauf at gcc dot gnu.org
  2023-08-17 18:37 ` anlauf at gcc dot gnu.org
  0 siblings, 2 replies; 3+ messages in thread
From: thod_ at gmx dot de @ 2023-08-11 15:18 UTC (permalink / raw)
  To: gcc-bugs

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)

^ permalink raw reply	[flat|nested] 3+ messages in thread

* [Bug fortran/110995] segfault for function in declaration of module function
  2023-08-11 15:18 [Bug fortran/110995] New: segfault for function in declaration of module function thod_ at gmx dot de
@ 2023-08-14 19:47 ` anlauf at gcc dot gnu.org
  2023-08-17 18:37 ` anlauf at gcc dot gnu.org
  1 sibling, 0 replies; 3+ messages in thread
From: anlauf at gcc dot gnu.org @ 2023-08-14 19:47 UTC (permalink / raw)
  To: gcc-bugs

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

anlauf at gcc dot gnu.org changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
   Last reconfirmed|                            |2023-08-14
             Status|UNCONFIRMED                 |NEW
     Ever confirmed|0                           |1

--- Comment #1 from anlauf at gcc dot gnu.org ---
Confirmed.

A reduced testcase giving the same failure may give some insight:

module strings
  implicit none
contains
  pure function charArrToString(data)
    character, intent(in) :: data(:)
!   character(size(data))       :: charArrToString ! OK
    character(ubound(data,1))   :: charArrToString ! ICE if used in main
    charArrToString = ""
  end function charArrToString
end module strings

program test_str
  use strings
  implicit none
  character :: c(2) = (/ 'T', 'T' /)
  write(*,*) "write module-", charArrToString(c),  "-" ! ICE
  write(*,*) "write module-", charArrToString2(c), "-" ! OK
contains
  pure function charArrToString2(data)
    character, intent(in) :: data(:)
!   character(size(data))       :: charArrToString2 ! OK
    character(ubound(data,1))   :: charArrToString2 ! OK
    charArrToString2 = ""
  end function charArrToString2
end program test_str

So (apparently):
- if the function definition is in the same compilation unit as where it is
  used, there is no problem.
- if the function interface is passed via a module file, some declarations
  work (e.g. using the SIZE intrinsic), but some don't (e.g. using a pure
  user-defined function, or some other intrinsics).

^ permalink raw reply	[flat|nested] 3+ messages in thread

* [Bug fortran/110995] segfault for function in declaration of module function
  2023-08-11 15:18 [Bug fortran/110995] New: segfault for function in declaration of module function thod_ at gmx dot de
  2023-08-14 19:47 ` [Bug fortran/110995] " anlauf at gcc dot gnu.org
@ 2023-08-17 18:37 ` anlauf at gcc dot gnu.org
  1 sibling, 0 replies; 3+ messages in thread
From: anlauf at gcc dot gnu.org @ 2023-08-17 18:37 UTC (permalink / raw)
  To: gcc-bugs

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

anlauf at gcc dot gnu.org changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
           See Also|                            |https://gcc.gnu.org/bugzill
                   |                            |a/show_bug.cgi?id=58157

--- Comment #2 from anlauf at gcc dot gnu.org ---
PR58157 is likely related.

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2023-08-17 18:37 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-08-11 15:18 [Bug fortran/110995] New: segfault for function in declaration of module function thod_ at gmx dot de
2023-08-14 19:47 ` [Bug fortran/110995] " anlauf at gcc dot gnu.org
2023-08-17 18:37 ` anlauf at gcc dot gnu.org

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).