This is kind of a split up of PR31564, which is unrelated.

The program is invalid as we pass an array as actual argument to the scalar
dummy argument; somehow gfortran does not detect this.

Interestingly, compare_actual_formal is never called if the actual argument is
an array section with non-expr-constant bounds. If it is a single element, or
the whole array or has e.g. bounds "1:1" or "1:2" everything is caught and goes
through compare_actual_formal, except for ":which", "1:which" etc.

The ICE is:
x.f90: In function 'cdf_beta':
x.f90:16: internal compiler error: in gfc_trans_call, at
fortran/trans-stmt.c:321


Testcase, from PR 31564 modified to produce invalid code.

    MODULE cdf_aux_mod
      TYPE :: the_distribution
        INTEGER :: parameters(1)
      END TYPE the_distribution
      TYPE (the_distribution), PARAMETER :: the_beta = the_distribution((/0/))
    CONTAINS
      SUBROUTINE set_bound(arg_name)
        INTEGER, INTENT (IN) :: arg_name
      END SUBROUTINE set_bound
    END MODULE cdf_aux_mod
    MODULE cdf_beta_mod
    CONTAINS
      SUBROUTINE cdf_beta()
        USE cdf_aux_mod
        INTEGER :: which
          which = 1
          CALL set_bound(the_beta%parameters(1:which))
      END SUBROUTINE cdf_beta
    END MODULE cdf_beta_mod


-- 
           Summary: ICE: Procedure call with array-section-actual to scalar
                    dummy
           Product: gcc
           Version: 4.3.0
            Status: UNCONFIRMED
          Keywords: ice-on-invalid-code
          Severity: normal
          Priority: P3
         Component: fortran
        AssignedTo: unassigned at gcc dot gnu dot org
        ReportedBy: burnus at gcc dot gnu dot org


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=32129

Reply via email to