[Bug fortran/58786] New: module function with passed character array of explicit length causes an ICE
stefan.mauerberger at gmail dot com
gcc-bugzilla@gcc.gnu.org
Fri Oct 18 13:56:00 GMT 2013
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=58786
Bug ID: 58786
Summary: module function with passed character array of
explicit length causes an ICE
Product: gcc
Version: unknown
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: fortran
Assignee: unassigned at gcc dot gnu.org
Reporter: stefan.mauerberger at gmail dot com
Hello There!
Assume a module function called "array_to_string()" whose return value is a
string. The length of the returned character is defined by the passed dummy
argument named "array" which is a character array of explicit length.
The length of the returned character shall be determined by
SUM(LEN_TRIM(array)). Well, invoking the elemental function LEN_TRIM(array)
causes an internal compiler error.
Please see the following example code. I know, it is tricky to explain:
> MODULE string_utilities_mod
>
> CONTAINS
>
> FUNCTION array_to_string(array) RESULT(str)
> CHARACTER(LEN=8) :: array(:)
> ! CHARACTER(LEN=*) :: array(:) ! Does not cause an ICE
> CHARACTER(LEN=SUM(LEN_TRIM(array))+1) :: str ! LEN_TRIM() is causing the ICE
>
> WRITE(str,*) array(:) ! Imagine some fancy code
>
> END FUNCTION array_to_string
>
> END MODULE string_utilities_mod
>
> PROGRAM test
> USE string_utilities_mod
>
> ! Just the invocation of array_to_string() causes an internal compiler error
> PRINT *, array_to_string(['aaaaaaaa','bbbbbbbb'])
>
> CONTAINS
>
> ! Everything works fine if array_to_string() is defined here
>
> END PROGRAM test
The above example has been tested with:
* Ifort 12.1 => ok
* nagfor 5.3 => ok
* pgfortran 13.8 => ok
However:
* gfortran 4.4.5 => ICE
* gfortran 4.7.2 => ICE
* grfotran 4.8.1 => ICE
* gfortran 4.9. => ICE
Cheers, Stefan
bug.f90: In function ‘test’:
bug.f90:20:0: internal compiler error: Segmentation fault
PRINT *, array_to_string(['aaaaaaaa','bbbbbbbb'])
^
0x9ad52f crash_signal
../../gcc_trunk_src/gcc/toplev.c:335
0x7b3388 contains_struct_check
../../gcc_trunk_src/gcc/tree.h:2787
0x7b3388 size_binop_loc(unsigned int, tree_code, tree_node*, tree_node*)
../../gcc_trunk_src/gcc/fold-const.c:1492
0x81cff8 gimplify_compound_lval
../../gcc_trunk_src/gcc/gimplify.c:2214
0x815ff9 gimplify_expr(tree_node**, gimple_statement_d**, gimple_statement_d**,
bool (*)(tree_node*), int)
../../gcc_trunk_src/gcc/gimplify.c:7631
0x822e15 gimplify_addr_expr
../../gcc_trunk_src/gcc/gimplify.c:5073
0x8162be gimplify_expr(tree_node**, gimple_statement_d**, gimple_statement_d**,
bool (*)(tree_node*), int)
../../gcc_trunk_src/gcc/gimplify.c:7725
0x81ef49 gimplify_call_expr
../../gcc_trunk_src/gcc/gimplify.c:2645
0x815cb8 gimplify_expr(tree_node**, gimple_statement_d**, gimple_statement_d**,
bool (*)(tree_node*), int)
../../gcc_trunk_src/gcc/gimplify.c:7650
0x816a49 gimplify_expr(tree_node**, gimple_statement_d**, gimple_statement_d**,
bool (*)(tree_node*), int)
../../gcc_trunk_src/gcc/gimplify.c:8323
0x821f88 gimplify_modify_expr
../../gcc_trunk_src/gcc/gimplify.c:4772
0x815e64 gimplify_expr(tree_node**, gimple_statement_d**, gimple_statement_d**,
bool (*)(tree_node*), int)
../../gcc_trunk_src/gcc/gimplify.c:7679
0x81a196 gimplify_stmt(tree_node**, gimple_statement_d**)
../../gcc_trunk_src/gcc/gimplify.c:5613
0x81703b gimplify_statement_list
../../gcc_trunk_src/gcc/gimplify.c:1535
0x81703b gimplify_expr(tree_node**, gimple_statement_d**, gimple_statement_d**,
bool (*)(tree_node*), int)
../../gcc_trunk_src/gcc/gimplify.c:8068
0x81a196 gimplify_stmt(tree_node**, gimple_statement_d**)
../../gcc_trunk_src/gcc/gimplify.c:5613
0x817f7a gimplify_and_add
../../gcc_trunk_src/gcc/gimplify.c:339
0x817f7a gimplify_loop_expr
../../gcc_trunk_src/gcc/gimplify.c:1509
0x817f7a gimplify_expr(tree_node**, gimple_statement_d**, gimple_statement_d**,
bool (*)(tree_node*), int)
../../gcc_trunk_src/gcc/gimplify.c:7854
0x81a196 gimplify_stmt(tree_node**, gimple_statement_d**)
../../gcc_trunk_src/gcc/gimplify.c:5613
More information about the Gcc-bugs
mailing list