[Bug fortran/78659] New: Spurious "requires DTIO" reported against namelist statement
ian_harvey at bigpond dot com
gcc-bugzilla@gcc.gnu.org
Sat Dec 3 01:38:00 GMT 2016
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=78659
Bug ID: 78659
Summary: Spurious "requires DTIO" reported against namelist
statement
Product: gcc
Version: 7.0
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: fortran
Assignee: unassigned at gcc dot gnu.org
Reporter: ian_harvey at bigpond dot com
Target Milestone: ---
The attached, when compiled with gfortran recent trunk (r243203):
MODULE ma
IMPLICIT NONE
TYPE :: ta
INTEGER, ALLOCATABLE :: array(:)
END TYPE ta
END MODULE ma
PROGRAM p
USE ma
TYPE(ta) :: x
NAMELIST /nml/ x
END PROGRAM p
results in:
$ gfortran 2016-12-03\ dtio-namelist-1.f90
2016-12-03 dtio-namelist-1.f90:11:15:
NAMELIST /nml/ x
1
Error: NAMELIST object ‘x’ in namelist ‘nml’ at (1) has ALLOCATABLE or POINTER
components and thus requires a defined input/output procedure
The error is reported against the namelist statement. The standard does not
impose such a requirement on the namelist statement itself - the requirement is
imposed on data transfer statements that reference the namelist (F2008
9.6.4.7p2).
A namelist with such an object is not useful, so a warning is perhaps warranted
specifically for the above code, but the current error message causes issues
with useful code, such as:
MODULE mb
IMPLICIT NONE
TYPE :: tb
INTEGER, ALLOCATABLE :: array(:)
CONTAINS
PROCEDURE :: read_formatted
GENERIC :: READ(FORMATTED) => read_formatted
END TYPE tb
CONTAINS
SUBROUTINE read_formatted(dtv, unit, iotype, v_list, iostat, iomsg)
CLASS(tb), INTENT(INOUT) :: dtv
INTEGER, INTENT(IN) :: unit
CHARACTER(*), INTENT(IN) :: iotype
INTEGER, INTENT(IN) :: v_list(:)
INTEGER, INTENT(OUT) :: iostat
CHARACTER(*), INTENT(INOUT) :: iomsg
iostat = 0
END SUBROUTINE read_formatted
END MODULE mb
PROGRAM p
USE mb
TYPE(tb) :: y
NAMELIST /nml/ y
READ (*, nml)
END PROGRAM p
$ gfortran 2016-12-03\ dtio-namelist-2.f90
2016-12-03 dtio-namelist-2.f90:25:15:
NAMELIST /nml/ y
1
Error: NAMELIST object ‘y’ in namelist ‘nml’ at (1) has ALLOCATABLE or POINTER
components and thus requires a defined input/output procedure
The error goes away if a defined output procedure is also provided, but the
standard does not require a defined output procedure for the last example.
More information about the Gcc-bugs
mailing list