https://gcc.gnu.org/bugzilla/show_bug.cgi?id=128719
Bug ID: 128719
Summary: WAIT with ID= returns before the asynchronous
statement with that ID completes
Product: gcc
Version: 15.2.0
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: libfortran
Assignee: unassigned at gcc dot gnu.org
Reporter: suvarchal.cheedela at awi dot de
Target Milestone: ---
Created attachment 66161
--> https://gcc.gnu.org/bugzilla/attachment.cgi?id=66161&action=edit
wait_id program to test
WAIT (unit, ID=id) returns as soon as the operation *before* the one with
the given ID has finished. For the first ID of a unit it does not wait at
all. async_wait_id in libgfortran/io/async.c waits for id.low >= id, but
id.low counts completed operations, so the condition should be
id.low > id. Programs mostly look correct because CLOSE waits for
everything. Also present on trunk (17.0.0 20261113).
$ gfortran -O2 -pthread wait_id.f90 && ./a.out
after WAIT(ID=id1): 0 of 12500000 bytes on disk
BUG: WAIT returned before the statement completed
Expected: all 12500000 bytes (minus at most one buffer) on disk after
the WAIT.
! WAIT (ID=) must not return before the statement with that ID is complete.
! Prints how much of the first statement's output is on disk right after
! WAIT (ID=id1). Expected: all of it.
program wait_id
implicit none
integer, parameter :: n = 500000
real(8), allocatable, asynchronous :: a(:)
integer :: id1, id2, i
integer(8) :: sz, expected
allocate (a(n))
a = [(1.0d0 + i, i = 1, n)]
expected = int (n, 8) * 25
open (10, file='wait_id.dat', asynchronous='yes', status='replace')
write (10, '(es24.16)', asynchronous='yes', id=id1) a
write (10, '(es24.16)', asynchronous='yes', id=id2) a(1:10)
wait (10, id=id1)
inquire (file='wait_id.dat', size=sz)
print '(a,i0,a,i0,a)', 'after WAIT(ID=id1): ', sz, ' of ', expected, ' bytes
on disk'
if (sz < expected - 8192) then
print '(a)', 'BUG: WAIT returned before the statement completed'
else
print '(a)', 'OK'
end if
close (10, status='delete')
end program wait_id