<table border="1" cellspacing="0" cellpadding="8">
<tr>
<th>Issue</th>
<td>
<a href=https://github.com/llvm/llvm-project/issues/77037>77037</a>
</td>
</tr>
<tr>
<th>Summary</th>
<td>
[flang][runtime] Runtime error for INQUIRE with UNIT 64-bit integer
</td>
</tr>
<tr>
<th>Labels</th>
<td>
bug,
flang:runtime
</td>
</tr>
<tr>
<th>Assignees</th>
<td>
</td>
</tr>
<tr>
<th>Reporter</th>
<td>
NimishMishra
</td>
</tr>
</table>
<pre>
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
```
</pre>
<img width="1px" height="1px" alt="" src="http://email.email.llvm.org/o/eJzcVUtv4zYQ_jXUZWCDoiRbOuiQxHFX6Da7DeqzQVkjiQVFunwk6L8vqIdjL5qkaG81DMuaxzffNxJnuLWiU4glye5Jtou4d7025ZMYhO1_EbY3PKp182dZPf16qJ4fwTrucEDl4FW4Hg5P1W8k2YE940m0Ag24njsQFiQ33XSroMGWe-lAKIfB-MKN4LXECYPDC5cebzK-HH56JCyPCSvAoPXSWRAKOBivnBgQ0Bht1oTuCL2bfp_xbHTjT2hIcnftIBs6f8fb70Z3hg_g0LqjUH94YfAolNukkx_gYBEqq497bZzh6vioXhZXNZylOAkHT1rhxTjJIiyfYFgBgUJyB8Ir4X4IW3yhk4vrq-7EictLmj3qM6rFO6JAaHNMb5hWE3vC8kOok-ymeuwBvp1RYRMsMxQrFrTvRigHLES9W-eL73Bp_wpielt2hkhGiFuF_5zPA1R6bEGyGy8_EoyvCbKH63b9B9kfoL4jn7B7iP__8mPYazMEIvnXlLCHKr8ks1vXbE3erFWcXcyPqoH5hP3t6bsYW8lVt1L4Oh7EdVuEmHCsLWg_TxeyoWHAgPJDjQZYnG7TPNmkeRgwIUq3YLjqMKRy1UCrpdSvQnXBe_bu40kAAPv53wydpds3F0wf-oEFrjhdhcV0acd76rt2mi034o1XFr79HB7MKN_1-O8VXZH7TNWnej5pxIVE1JRJUyQFj7CMtzRNWZrTLOrLgmV8Q_MibjeIJ75JiiwpirahDUtr3taRKBllKY1pRhNGabZutjw5cZrXnLE6yXOSUhy4kGspX4a1Nl0krPVYbrc02UaS1yjtuMQYq31HWJhvhLHxLSPJ3bw2gj3bRaYMKKvad5akVArr7BuuE06O-3DKzXYku1_Ssx08Xy8gaLWBZTVeFiJs0lUtLusu8kaWvXNnGx4e2xO274Trfb0-6YGwfag8X1Zno3_HkyNsP8qzhO1HhX8FAAD__0a4NY0">