This is an archive of the discontinued LLVM Phabricator instance.

[flang] Set "undefined" NEXTREC=n variable to 0 rather than random garbage
ClosedPublic

Authored by klausler on Jun 6 2023, 11:44 AM.

Details

Summary

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.

Diff Detail

Event Timeline

klausler created this revision.Jun 6 2023, 11:44 AM
Herald added a project: Restricted Project. · View Herald TranscriptJun 6 2023, 11:44 AM
klausler requested review of this revision.Jun 6 2023, 11:44 AM
tarunprabhu accepted this revision.Jun 6 2023, 11:47 AM

LGTM. Thanks for fixing this.

This revision is now accepted and ready to land.Jun 6 2023, 11:47 AM
This revision was landed with ongoing or failed builds.Jun 6 2023, 11:58 AM
This revision was automatically updated to reflect the committed changes.

Is there an equivalent to -finit-integer=99999? If so, I think it would be preferable if this initialisation for an "undefined" variable respected that, in order to help when looking for uses of undefined variables, since referencing an undefined variable makes it invalid Fortran.