FRIDAY, JUNE 12, 2026
fortran
fortran: Fix segfault for DATA pointer init to an array element [PR125762]
Fixes a Fortran compiler segfault when initializing DATA pointers to array elements.
This commit resolves a segmentation fault in the Fortran compiler that occurred when initializing DATA pointers to specific elements of an array. The fix involves ensuring that the value expressions within DATA statements are properly resolved by calling gfc_resolve_expr on each expression.
In Details
Addresses a segfault in resolve.cc triggered by initializing DATA pointers to array elements. The fix involves modifying resolve_data to call gfc_resolve_expr on each value expression within the DATA statement, ensuring correct resolution and preventing the crash.
For Context
- DATA statement
- A Fortran statement used to initialize variables with specific values at compile time. This includes scalars, arrays, and structures.
- pointer
- In Fortran, a pointer is a variable that holds the address of another variable. It allows for dynamic memory allocation and indirect access to data.
- gfc_resolve_expr
- A function within the GCC Fortran front-end responsible for evaluating and resolving expression values, including those used in initializations and assignments. Correctly resolving expressions is crucial for accurate code generation.
- segfault
- Segmentation fault. An error signal generated by the operating system when a program attempts to access memory that it does not have permission to access, often indicating a bug in the program.