Bug 112700 - Segmentation fault with list of characters and types
Summary: Segmentation fault with list of characters and types
Status: NEW
Alias: None
Product: gcc
Classification: Unclassified
Component: fortran (show other bugs)
Version: 13.2.1
: P3 normal
Target Milestone: ---
Assignee: Not yet assigned to anyone
URL:
Keywords: ice-on-valid-code
Depends on:
Blocks:
 
Reported: 2023-11-24 13:59 UTC by Alexandre Poux
Modified: 2023-11-27 08:59 UTC (History)
0 users

See Also:
Host:
Target:
Build:
Known to work:
Known to fail:
Last reconfirmed: 2023-11-24 00:00:00


Attachments
a module triggerring a segmentation fault (221 bytes, text/plain)
2023-11-24 13:59 UTC, Alexandre Poux
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Alexandre Poux 2023-11-24 13:59:54 UTC
Created attachment 56679 [details]
a module triggerring a segmentation fault

The attached source code for a fortran module triggers a segmentation fault when compiling

```
bug_mod.f90:24:39:

   24 |         list_char = obj%get_char_list()
      |                                       1
internal compiler error: Segmentation fault
0xd432a1 internal_error(char const*, ...)
        ???:0
0xe409f5 fold_convert_loc(unsigned int, tree_node*, tree_node*)
        ???:0
0x15e8f14 gfc_trans_create_temp_array(stmtblock_t*, stmtblock_t*, gfc_ss*, tree_node*, tree_node*, bool, bool, bool, locus*)
        ???:0
0x1631d79 gfc_conv_procedure_call(gfc_se*, gfc_symbol*, gfc_actual_arglist*, gfc_expr*, vec<tree_node*, va_gc, vl_embed>*)
        ???:0
0x15f5151 gfc_conv_loop_setup(gfc_loopinfo*, locus*)
        ???:0
0x161d4f8 gfc_generate_function_code(gfc_namespace*)
        ???:0
0x15e7f29 gfc_generate_module_code(gfc_namespace*)
        ???:0
0x157973b gfc_parse_file()
        ???:0
Please submit a full bug report,
with preprocessed source if appropriate.
Please include the complete backtrace with any bug report.
See <file:///usr/share/doc/gcc-11/README.Bugs> for instructions.
```

I've been able to reproduce it with
- latest version of gfortran from the archlinux repository: core/gcc-fortran 13.2.1-3
- older version from ubuntu 22.04 : Ubuntu 11.4.0-1ubuntu1~22.04
Comment 1 anlauf 2023-11-24 19:31:11 UTC
The testcase has some similarity with reduced versions of pr93678
and also the same traceback.  Thus likely related.

Note: replacing the rank-1 result variable

    character(len=1) :: list(1)

by a scalar

    character(len=1) :: list !(1)

avoids the ICE.
Comment 2 Alexandre Poux 2023-11-27 08:59:23 UTC
Among the things that avoid the ICE:
- Using a subroutine instead of a function
- not using a type procedure but a regular function
- wrapping the list of char in a custom type
- returning a list of a real numbers

Among the things that do not avoid the ICE:
- replacing the fixed length array with a pointer or an allocatable