Fortran compiler fixes ICE with transpose(reshape()) of character arrays.
Fixed a Fortran compiler internal error when using transpose(reshape()) on character array constructors.
The Fortran compiler previously encountered an internal compiler error (ICE) when processing TRANSPOSE(RESHAPE()) applied to a character array constructor. This occurred because determining the character length required looking through function calls. The fix modifies gfc_get_expr_charlen to correctly retrieve character lengths by examining function results, resolving the ICE and enabling correct compilation of such constructs.
In Details
This commit resolves an ICE in the Fortran frontend (specifically in gcc/fortran/trans-expr.cc) when handling TRANSPOSE(RESHAPE()) of character array constructors. The issue stemmed from gfc_get_expr_charlen not properly propagating or resolving the character length attribute when the expression involved function calls (e.g., the result of RESHAPE which might involve complex transformations). The fix ensures that gfc_get_expr_charlen can traverse function calls to determine the correct character length, thereby preventing the ICE.
- ICE
- Internal Compiler Error. An unexpected condition encountered by the compiler during the compilation process, indicating a bug in the compiler itself.
- Fortran
- A high-level programming language primarily used for scientific and numerical computation.
- TRANSPOSE
- A Fortran intrinsic function that returns the transpose of an array.
- RESHAPE
- A Fortran intrinsic function that allows changing the shape (dimensions) of an array without changing its elements or order.
- array constructor
- A Fortran construct used to create an array literal, specifying its elements directly within the code.
- character length
- The number of characters in a string or character array.