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

             Bug #: 54223
           Summary: Statement function statement with dummy arguments that
                    are also OPTIONAL may crash in wrong calls
    Classification: Unclassified
           Product: gcc
           Version: unknown
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: fortran
        AssignedTo: unassig...@gcc.gnu.org
        ReportedBy: roger.fer...@bsc.es


Hi,

in the following non-conformant Fortran snippet

SUBROUTINE S(X)
    IMPLICIT NONE
    INTEGER, OPTIONAL :: X
    INTEGER :: F, Y

    ! Statement function statement
    F(X) = X + 1

    ! This call to F is wrong, it requires an actual argument here
    ! despite the X being OPTIONAL
    Y = F()
END SUBROUTINE S

causes gfortran 4.7.1 to crash

$ gfortran -c test.f90
test.f90: In function 's':
test.f90:11:0: internal compiler error: Segmentation fault
Please submit a full bug report,
with preprocessed source if appropriate.
See <file:///usr/share/doc/gcc-4.7/README.Bugs> for instructions.

I think that the OPTIONAL attribute is confusing gfortran when it checks
the (wrong) call to F.

Removing the OPTIONAL attribute results in gfortran properly diagnosing the
missing actual argument.

Kind regards,

Reply via email to