]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
Fortran: fix passing of component ref to assumed-rank dummy [PR118683]
authorHarald Anlauf <anlauf@gmx.de>
Tue, 28 Jan 2025 20:21:40 +0000 (21:21 +0100)
committerHarald Anlauf <anlauf@gmx.de>
Wed, 29 Jan 2025 07:47:37 +0000 (08:47 +0100)
While the fix for pr117774 addressed the passing of an inquiry reference
to an assumed-rank dummy, it missed the similar case of passing a component
reference.  The newer testcase gfortran.dg/pr81978.f90 uncovered this
latent issue with a UBSAN instrumented compiler.

PR fortran/118683

gcc/fortran/ChangeLog:

* trans-expr.cc (gfc_conv_procedure_call): The bounds update for
passing to assumed-rank dummies shall also handle component
references besides inquiry references.

gcc/fortran/trans-expr.cc

index 78caf1f8996c94f3d803cde09c8f76194b73fada..24b1d19537bba44f9aa6a4530f096d2669b157f3 100644 (file)
@@ -7495,6 +7495,9 @@ gfc_conv_procedure_call (gfc_se * se, gfc_symbol * sym,
                    {
                      if (ref->next->type == REF_INQUIRY)
                        break;
+                     if (ref->type == REF_ARRAY
+                         && ref->u.ar.type != AR_ELEMENT)
+                       break;
                    };
                  if (ref->u.ar.type == AR_FULL
                      && ref->u.ar.as->type != AS_ASSUMED_SIZE)