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/41177] New: Wrong base-object checks for type-bound procedures


ELEMENTAL type-bound procedures (and in consequence also, for instance,
type-bound operators or assignments on arrays) do not work for non-scalar
passed-objects (even though the procedures are ELEMENTAL):

MODULE m
  IMPLICIT NONE

  TYPE t
  CONTAINS
    PROCEDURE, PASS :: myproc
  END TYPE t

CONTAINS

  ELEMENTAL INTEGER FUNCTION myproc (me)
    CLASS(t), INTENT(IN) :: me
    myproc = 42
  END FUNCTION myproc

END MODULE m

PROGRAM main
  USE m
  IMPLICIT NONE

  TYPE(t) :: arr(2)
  PRINT *, arr%myproc ()
END PROGRAM main

[/tmp]# gfortran-dev elemental.f03  -w
elemental.f03:23.10:

  PRINT *, arr%myproc ()
          1
Error: Passed-object at (1) must be scalar

This is a wrongly placed check; actually, on the declaration it should be
checked that the passed-object dummy argument is scalar, non-pointer and
non-allocatable, but that check is in turn missing; this one is accepted but is
illegal:

MODULE m
  IMPLICIT NONE

  TYPE t
  CONTAINS
    PROCEDURE, PASS :: proc1
    PROCEDURE, PASS :: proc2
  END TYPE t

CONTAINS

  INTEGER FUNCTION proc1 (me)
    CLASS(t), INTENT(IN) :: me(:)
    proc1 = 42
  END FUNCTION proc1

  INTEGER FUNCTION proc2 (me)
    CLASS(t), INTENT(IN), POINTER :: me
    proc2 = 42
  END FUNCTION proc2

  ! ALLOCATABLE scalar can't be checked, but is the same.

END MODULE m


-- 
           Summary: Wrong base-object checks for type-bound procedures
           Product: gcc
           Version: unknown
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: fortran
        AssignedTo: unassigned at gcc dot gnu dot org
        ReportedBy: domob at gcc dot gnu dot org


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


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