Fortran: Fix absent optional VALUE dummy argument segfaults
Fixes segfaults when an absent optional argument is passed to a VALUE dummy in Fortran.
This change corrects a segfault in gfortran that occurred when an absent optional actual argument was passed to a Fortran dummy argument with the VALUE attribute. The compiler now correctly suppresses copies for absent optional arguments, preventing dereferencing of null pointers for both array and character types, thus ensuring program stability.
In Details
The Fortran compiler now correctly handles passing absent optional actual arguments to VALUE dummy arguments. Previously, the compiler unconditionally created a private copy for VALUE dummies, leading to a segfault when the actual argument was absent. Changes in trans-expr.cc suppress this copy for absent optional arguments in both array and character cases, preventing null pointer dereferences.
- VALUE attribute
- In Fortran, when applied to a dummy argument, this attribute specifies that the argument is passed by value, meaning a private copy is made for the procedure. Changes within the procedure do not affect the actual argument.
- absent optional actual argument
- An argument that is declared as optional in a procedure interface but is not provided when the procedure is called.
- segfault
- Segmentation fault. An error that occurs when a program attempts to access a memory location that it is not allowed to access.
- gfortran
- The GNU Fortran compiler, part of the GCC suite.