This is the mail archive of the gcc-bugs@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[Bug fortran/51758] New: ICE with optional arguments of elemental procedures


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

             Bug #: 51758
           Summary: ICE with optional arguments of elemental procedures
    Classification: Unclassified
           Product: gcc
           Version: 4.7.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: fortran
        AssignedTo: unassigned@gcc.gnu.org
        ReportedBy: mikael@gcc.gnu.org


Follow-up to PR50981.

gfortran chokes with the testcase below.

with 4.7:
   internal compiler error: in gfc_trans_assignment_1, at
fortran/trans-expr.c:6794

The code is accepted without the elemental cases, and the null() seems to be
handled correctly.


with 4.5:
  a = foo((/ 1, 1 /), null())
                      1
Error: Rank mismatch in argument 'b' at (1) (1 and 0)

The code is accepted without the non-elemental case, but the null() is
mishandled.




program p

  integer :: a(2)
  integer :: b

  a = 0
  a = foo((/ 1, 1 /), null())
  print *, a
  !if (any(a /= 2)) call abort

  a = 0
  a = bar((/ 1, 1 /), null())
  print *, a
  !if (any(a /= 2)) call abort

! b = 0
! b = bar(1, null())
! print *, a
  !if (b /= 2) call abort

contains

  function foo(a, b)
    integer           :: a(:)
    integer, optional :: b(:)
    integer           :: foo(size(a))

    if (present(b)) call abort

    foo = 2
  end function foo

  elemental function bar(a, b)
    integer, intent(in)           :: a
    integer, intent(in), optional :: b
    integer                       :: bar

    bar = 2

    if (present(b)) bar = 1

  end function bar

end program p


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]