https://gcc.gnu.org/bugzilla/show_bug.cgi?id=125481
--- Comment #4 from GCC Commits <cvs-commit at gcc dot gnu.org> --- The releases/gcc-16 branch has been updated by Jerry DeLisle <[email protected]>: https://gcc.gnu.org/g:4be6a034de56f1aed40e4fa0113d192f4ca4de7a commit r16-9109-g4be6a034de56f1aed40e4fa0113d192f4ca4de7a Author: Jerry DeLisle <[email protected]> Date: Tue May 26 12:00:33 2026 -0700 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)
