<table border="1" cellspacing="0" cellpadding="8">
<tr>
<th>Issue</th>
<td>
<a href=https://github.com/llvm/llvm-project/issues/71342>71342</a>
</td>
</tr>
<tr>
<th>Summary</th>
<td>
[Flang][OpenMP] Execution error of `if` clause with a temporary array
</td>
</tr>
<tr>
<th>Labels</th>
<td>
flang:ir,
flang:openmp
</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 temporary array is made in the `if` clause.
If the condition in `if` clause is replaced with another temporary variable, the error doesn't occur.
The following are the test program, Flang-new and gfortran execution result.
```fortran
! test.f90
program omp
integer(4),dimension(2,2)::a
a=reshape((/-1,0,1,2/),(/2,2/))
call sub(a)
end program
subroutine sub(a)
integer(4),dimension(2,2)::a
!$omp parallel if(any(a/=reshape((/-1,0,1,1/),(/2,2/))))
!$omp end parallel
!$omp parallel if(any(a/=reshape((/-1,0,1,1/),(/2,2/))))
!$omp end parallel
end subroutine
```
```console
$ flang-new -v test.f90 -fopenmp
flang-new version 18.0.0 (https://github.com/llvm/llvm-project.git 4ac304242b65413f4eae21af300dd14cb14ed066)
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 -fopenmp -fcolor-diagnostics -mrelocation-model pic -pic-level 2 -pic-is-pie -target-cpu generic -target-feature +neon -target-feature +v8a -o /tmp/test-08be19.o -x f95-cpp-input test.f90
"/opt/rh/gcc-toolset-12/root/usr/lib/gcc/aarch64-redhat-linux/12/../../../../bin/ld" -pie -EL --hash-style=gnu --eh-frame-hdr -m aarch64linux -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 -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-08be19.o -L/path/to/install/lib -lFortran_main -lFortranRuntime -lFortranDecimal -lm -lomp -L/path/to/install/lib -lgcc --as-needed -lgcc_s --no-as-needed -lpthread -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
$ OMP_NUM_THREADS=2 ./a.out
double free or corruption (fasttop)
Aborted (core dumped)
```
```console
$ gfortran -v test.f90 -fopenmp
Driving: gfortran -v test.f90 -fopenmp -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)
:
$ OMP_NUM_THREADS=2 ./a.out
$
```
</pre>
<img width="1px" height="1px" alt="" src="http://email.email.llvm.org/o/eJzMWN1v2zgS_2uYlwEFiZJd-yEPrl3tLpBeizaLewwociSzpUgdP5L4_voDJfkjaZNuge5hgcCtZobDmd98cEjuveoM4jVZvCWL3RWPYW_d9SH68k2R0_bLVWPl4fp2rzwoD9yA8j4itM72UMcvKvgIAX3wUQXMSL4j-Wb6vd0j4COKGJQ1YFvgMDjbOd6DsP2gNEpoDtBqbjpq8AECul4ZHtDDgwp74NDywDWgc9bNqv8wEPZ4VETYFjgE7AfruDsAd44fkp09lwhqkiXLXLVkmYPQPPqjjX-0I1NYI9VooDLPJZMih4PmAuVskbFhj-5ix3vuFG80JkuSvtFWkBa9IexNACtEdN_A0lqt7YMyHXCH47oE4aVX9QkVbiR0rXXBcXOBp0MfdXiimSzz6W-WnqmsGLVn7TqfKABwioTth5moTMAOHWGrirA1YVupejReWUPYihG2ZYlcbki54Wc9AJyUO4d-zwckbDX-1bQgbJsTti2mdfWkcWKyS9p6ViW41uBjQ9iKn6kAgEaecLnwNbF8bJyNQRn8duXPe3NCi7DK9gMM3HGtUYNqk2pzmDaof-Ru8bq7F06f9xqdnPf751pzDMcZ92d59-xTWOOtPgqx6qLU6f0pJ4G2dkBzzMOzzD26FC8oVlme5UDYah_C4FPQkv11p8I-NpmwPWG11vfHf-jg7BcUIetUgIqLMq9YxZrloirKtkKOrOBtmedSFpVoigplvlyeYLjlrsNAyg1w7sR-WdFovhr7YKhWJj7SzsRjHTvkEnorUSfxwXr1eGxSPiT05E65xCKsHnjYE1YHS1itJjZhdaPmIq1tNBIEN1JJHhB-225hFuOp3GctdgiE1S5p6oSgwVrtMdAiRdRZm5jRu4SDaiYZwuqjHw7lnofJDcLqgk1bf0aNIqD8f-65PTnaRx1UWlluICPlW1Ll_bJ6ZtlrQkAYexVfVp9SijAGtBUF0ODUoPHlEAPFXgVqmy-n9EwrrbaOSsU7Y31QwgPtHWorRrzomAowKAF0UIJqvEc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