Skip to content

[flang][runtime] Runtime error for INQUIRE with UNIT 64-bit integer #77037

Open
@NimishMishra

Description

@NimishMishra

INQUIRE statement with UNIT= specifier that is larger than default integer variable with a value larger than HUGE(1) results in a runtime error.

Reproducer:

Program test_inquire_int64
  Use Iso_Fortran_Env
  Implicit None
  Integer(int64) :: iunit
  Integer :: stat
  Logical :: is_open
  iunit = 10_int64
  Inquire(Unit=iunit, Opened=is_open)
  Print 2, is_open
  iunit = Huge(1) - 100_int64
  Print 3, iunit
  Inquire(Unit=iunit, Opened=is_open, Iostat=stat)
  Print 1, is_open, stat
  Inquire(Unit=iunit, Opened=is_open)
  Print 1, is_open, stat
  iunit = Huge(1) + 1_int64
  Print 3, iunit
  Inquire(Unit=iunit, Opened=is_open, Iostat=stat)
  Print 1, is_open, stat
  Inquire(Unit=iunit, Opened=is_open)
  Print 1, is_open, stat
1 Format(L4,I8)
2 Format(L4)
3 Format(I15)
End Program

flang-new test.f90 errs out with UNIT number 2147483648 is out of range and following output:

   F
     2147483547
   F       0
   F       0
     2147483648
   F    1029

gfortran test.f90 runs OK, with the following output:

   F
     2147483547
   F       0
   F       0
     2147483648
   F       0
   F       0

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugIndicates an unexpected problem or unintended behaviorflang:runtime

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions