Fortran: Fixes data corruption with allocatable array components.
This commit resolves a data corruption issue in Fortran when passing non-contiguous slices of allocatable arrays to procedures expecting g77-style arguments.
This commit fixes a data corruption bug in the Fortran front-end that occurred when passing a non-contiguous slice of an allocatable array component to a procedure expecting a g77-style argument. The issue was caused by incorrect deallocation during inline packing. The fix ensures that the argument is not deallocated when passing a g77-style array. This is a regression affecting all supported releases.
In Details
The patch modifies gfc_conv_subref_array_arg in trans-expr.cc to prevent incorrect deallocation of g77-style array arguments. The core issue involves the interaction between inline packing (introduced in PR fortran/88821) and the handling of allocatable array components. Familiarity with the Fortran front-end's code generation and argument passing conventions is essential.
For Context
In Fortran, allocatable arrays are arrays whose size is determined during program execution. This commit addresses a bug that could cause data corruption when passing sections of allocatable arrays to subroutines or functions. The fix specifically relates to how the compiler handles older Fortran (g77-style) argument passing conventions. By correcting the memory management in this scenario, the compiler ensures that data is not inadvertently overwritten or lost.