Issue 77037
Summary [flang][runtime] Runtime error for INQUIRE with UNIT 64-bit integer
Labels bug, flang:runtime
Assignees
Reporter 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
```
_______________________________________________
llvm-bugs mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-bugs

Reply via email to