[flang] Set "undefined" NEXTREC=n variable to 0 rather than random garbage
authorPeter Klausler <pklausler@nvidia.com>
Tue, 6 Jun 2023 18:37:52 +0000 (11:37 -0700)
committerPeter Klausler <pklausler@nvidia.com>
Tue, 6 Jun 2023 18:58:01 +0000 (11:58 -0700)
commite468f07550c56eeb49659d02c7c5c3f79f53db6f
tree95ad92d53bfa02bba7b54814e42f517a80811589
parent9a81b697575244fb8a2f2e24188381c5d69f7bbe
[flang] Set "undefined" NEXTREC=n variable to 0 rather than random garbage

12.10.2.17 defines that a INQUIRE statement's NEXTREC=n output value
for a unit that is not connected for direct access becomes undefined,
but the current I/O runtime can fail in a confusing manner by trying
to return uninitialized stack garbage.

Reported on Slack by Tarun Prabhu as an intermittent failure in
the gfortran regression test inquire_pre.f90.

Differential Revision: https://reviews.llvm.org/D152295
flang/runtime/io-api.cpp