https://gcc.gnu.org/bugzilla/show_bug.cgi?id=125481
--- Comment #3 from GCC Commits <cvs-commit at gcc dot gnu.org> --- The master branch has been updated by Jerry DeLisle <[email protected]>: https://gcc.gnu.org/g:47bdd0d174e1823506a7e0dba3bfa84b3dddb14f commit r17-1144-g47bdd0d174e1823506a7e0dba3bfa84b3dddb14f 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 gcc/fortran/ChangeLog: PR fortran/125481 * 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: PR fortran/125481 * gfortran.dg/generic_37.f90: New test. * gfortran.dg/generic_38.f90: New test.
