https://gcc.gnu.org/g:3f37c6f47cd50c99350e93ef0dab31f7dc6d213a

commit r15-3782-g3f37c6f47cd50c99350e93ef0dab31f7dc6d213a
Author: Hans-Peter Nilsson <h...@axis.com>
Date:   Mon Sep 23 03:29:02 2024 +0200

    testsuite/gfortran.dg/unsigned_22.f90: Add missing close with delete, 
PR116701
    
    Without this patch, gfortran.dg/unsigned_22.f90 fails for
    non-effective-target fd_truncate targets, i.e. targets that
    don't support chsize or ftruncate.  See also
    libgfortran/io/unix.c:raw_truncate.  It passes on the first
    run, but leaves behind a file "fort.10" which is then picked
    up by subsequent runs, but since that file is to be
    rewritten, the libgfortran machinery tries to truncate it,
    which fails.  The file always being left behind, is
    primarily because the test-case lacks a deleting
    close-statement, apparently accidentally.
    
    Incidentally, this "fort.10" artefact is also picked up by
    gfortran.dg/write_check3.f90 causing that test to fail too,
    observable as a regression for non-fd_truncate targets since
    the unsigned_22.f90 introduction.  Also, when running
    e.g. the whole of gfortran.dg/dg.exp, the "fort.10" is later
    deleted by gfortran.dg/write_direct_eor.f90 (which
    regardlessly passes), erasing the clue of the cause of the
    write_check3 failure.  Also, running just
    dg.exp=write_check3.f90 or manually repeating the commands
    in gfortran.log showed no error.
    
    N.B.: this close-statement will not help if unsigned_22 for
    some reason fails, executing one of the "stop" statements,
    but that's also the case for many other tests.
    
            PR testsuite/116701
            * gfortran.dg/unsigned_22.f90: Add missing close with delete.

Diff:
---
 gcc/testsuite/gfortran.dg/unsigned_22.f90 | 1 +
 1 file changed, 1 insertion(+)

diff --git a/gcc/testsuite/gfortran.dg/unsigned_22.f90 
b/gcc/testsuite/gfortran.dg/unsigned_22.f90
index bc2f810238de..2a8434ccb6ec 100644
--- a/gcc/testsuite/gfortran.dg/unsigned_22.f90
+++ b/gcc/testsuite/gfortran.dg/unsigned_22.f90
@@ -22,4 +22,5 @@ program memain
   read (10,*,iostat=iostat,iomsg=iomsg) u
   if (iostat == 0) error stop 7
   if (iomsg /= "Unsigned integer overflow while reading item 1 of list input") 
error stop 8
+  close(unit=10, status='delete')
  end program memain

Reply via email to