https://gcc.gnu.org/bugzilla/show_bug.cgi?id=78854
--- Comment #12 from Jerry DeLisle <jvdelisle at gcc dot gnu.org> --- Here is a modified test case where I test the iotype and if its is NAMELIST, I format the output to what would be expected. Since there is no user defined namelist read, it just uses default reading of the namelist. MODULE m IMPLICIT NONE TYPE :: t CHARACTER :: c CONTAINS PROCEDURE :: write_formatted GENERIC :: WRITE(FORMATTED) => write_formatted END TYPE CONTAINS SUBROUTINE write_formatted(dtv, unit, iotype, v_list, iostat, iomsg) CLASS(t), INTENT(IN) :: dtv INTEGER, INTENT(IN) :: unit CHARACTER(*), INTENT(IN) :: iotype INTEGER, INTENT(IN) :: v_list(:) INTEGER, INTENT(OUT) :: iostat CHARACTER(*), INTENT(INOUT) :: iomsg if (iotype.eq."NAMELIST") then WRITE (unit, '(a,a,a)') 'x%c="',dtv%c,'",' else write (unit,*) dtv%c end if END SUBROUTINE END MODULE PROGRAM p USE m IMPLICIT NONE character(len=50) :: buffer TYPE(t) :: x NAMELIST /nml/ x x = t('a') WRITE (buffer, nml) write(*,nml) print *, buffer x = t('x') print *, x%c READ (buffer, nml) print *, x%c END The output with the preliminary patch is: $ ./a.out &NML x%c="a", / &NML x%c="a", / x a So it appears the basic namelist to buffer I/O is working correctly. The next step will be to decide exactly how to format the namelist writes/reads.