gnu/gcc/4be6a034de56f1aed40e4fa0113d192f4ca4de7a fortran: wrong generic resolution when actual argument is a procedure pointer
When a generic interface has two specific procedures -- one with a
procedure-pointer dummy and one with a data-object (e.g. REAL) dummy --
gfortran incorrectly resolved calls where the actual argument was a
procedure pointer to the data-object specific, resulting in the pointer
address being interpreted as a numeric value (wrong code).
The root cause was a missing check in gfc_compare_actual_formal: the
two existing checks guard the case where the formal is a proc_pointer
or FL_PROCEDURE but the actual is not; however the reverse direction
(actual is a proc_pointer but formal is a plain data object) was not
checked. F23:15.5.2.5, para 2 forbids this pairing.
Assisted-by: Claude Sonnet 4.6
PR fortran/125481
gcc/fortran/ChangeLog:
* interface.cc (gfc_compare_actual_formal): Add missing check that
rejects a procedure-pointer actual argument corresponding to a
data-object dummy argument (F23:15.5.2.5, para 2). Restrict to
EXPR_VARIABLE to avoid false positives on calls through procedure
pointer components.
gcc/testsuite/ChangeLog:
* gfortran.dg/generic_37.f90: New test.
* gfortran.dg/generic_38.f90: New test.
(cherry picked from commit 7537196aef7c2a430de1064cc5922ffa2e3cabbe)
3 files changed