<table border="1" cellspacing="0" cellpadding="8">
<tr>
<th>Issue</th>
<td>
<a href=https://github.com/llvm/llvm-project/issues/79255>79255</a>
</td>
</tr>
<tr>
<th>Summary</th>
<td>
[Flang] Execution error of a large number as a repeat specification
</td>
</tr>
<tr>
<th>Labels</th>
<td>
flang:runtime
</td>
</tr>
<tr>
<th>Assignees</th>
<td>
</td>
</tr>
<tr>
<th>Reporter</th>
<td>
yus3710-fj
</td>
</tr>
</table>
<pre>
This is an issue from Fujitsu testsuite.
The execution of a program compiled by flang-new terminates with a fatal error.
In the program, a large number (the maximum number of `INTEGER(4)`) is used as a repeat specification in a format specification.
Flang doesn't violate the Fortran standard but some other compilers support this number as a repeat specification.
The following are the test program and the execution result of Flang-new, gfortran and ifort.
```fortran
! test.f90
integer ::n_part(10)=1
write(1,'(32767(tr1,i0))') n_part
write(1,'(32768(tr1,i0))') n_part
write(1,'(1000000(tr1,i0))') n_part
write(1,'(2147483647(tr1,i0))') n_part
print *,'ok'
end
```
```console
$ flang-new -v test.f90
flang-new version 18.0.0git (https://github.com/llvm/llvm-project.git 2759e47067ea286f6302adcfe93b653cfaf6f2eb)
Target: aarch64-unknown-linux-gnu
Thread model: posix
InstalledDir: /path/to/install/bin
Found candidate GCC installation: /opt/rh/gcc-toolset-12/root/usr/lib/gcc/aarch64-redhat-linux/12
Selected GCC installation: /opt/rh/gcc-toolset-12/root/usr/lib/gcc/aarch64-redhat-linux/12
Candidate multilib: .;@m64
Selected multilib: .;@m64
"/path/to/install/bin/flang-new" -fc1 -triple aarch64-unknown-linux-gnu -emit-obj -fcolor-diagnostics -mrelocation-model pic -pic-level 2 -pic-is-pie -target-cpu generic -target-feature +v8a -target-feature +fp-armv8 -target-feature +neon -mframe-pointer=non-leaf -o /tmp/test-e0a21e.o -x f95-cpp-input test.f90
"/opt/rh/gcc-toolset-12/root/usr/lib/gcc/aarch64-redhat-linux/12/../../../../bin/ld" -EL --hash-style=gnu --eh-frame-hdr -m aarch64linux -pie -dynamic-linker /lib/ld-linux-aarch64.so.1 -o a.out /lib/../lib64/Scrt1.o /lib/../lib64/crti.o /opt/rh/gcc-toolset-12/root/usr/lib/gcc/aarch64-redhat-linux/12/crtbeginS.o -L/path/to/install/lib/clang/18/lib/aarch64-unknown-linux-gnu -L/opt/rh/gcc-toolset-12/root/usr/lib/gcc/aarch64-redhat-linux/12 -L/opt/rh/gcc-toolset-12/root/usr/lib/gcc/aarch64-redhat-linux/12/../../../../lib64 -L/lib/../lib64 -L/usr/lib/../lib64 -L/lib -L/usr/lib /tmp/test-e0a21e.o -L/path/to/install/lib --whole-archive -lFortran_main --no-whole-archive -lFortranRuntime -lFortranDecimal -lm -lgcc --as-needed -lgcc_s --no-as-needed -lc -lgcc --as-needed -lgcc_s --no-as-needed /opt/rh/gcc-toolset-12/root/usr/lib/gcc/aarch64-redhat-linux/12/crtendS.o /lib/../lib64/crtn.o
$ ./a.out
fatal Fortran runtime error(/path/to/test.f90:6): FORMAT integer field out of range
Aborted (core dumped)
```
```console
$ gfortran -v test.f90
Driving: gfortran -v test.f90 -l gfortran -l m -shared-libgcc
Using built-in specs.
COLLECT_GCC=gfortran
COLLECT_LTO_WRAPPER=/usr/libexec/gcc/aarch64-redhat-linux/8/lto-wrapper
Target: aarch64-redhat-linux
Configured with: ../configure --enable-bootstrap --enable-languages=c,c++,fortran,lto --prefix=/usr --mandir=/usr/share/man --infodir=/usr/share/info --with-bugurl=https://bugs.rockylinux.org/ --enable-shared --enable-threads=posix --enable-checking=release --enable-multilib --with-system-zlib --enable-__cxa_atexit --disable-libunwind-exceptions --enable-gnu-unique-object --enable-linker-build-id --with-gcc-major-version-only --with-linker-hash-style=gnu --enable-plugin --enable-initfini-array --with-isl --disable-libmpx --enable-gnu-indirect-function --build=aarch64-redhat-linux
Thread model: posix
gcc version 8.5.0 20210514 (Red Hat 8.5.0-18) (GCC)
:
$ ./a.out
ok
```
```console
$ ifort -v test.f90
ifort version 2021.10.0
:
$ ./a.out
ok
```
</pre>
<img width="1px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