<table border="1" cellspacing="0" cellpadding="8">
<tr>
<th>Issue</th>
<td>
<a href=https://github.com/llvm/llvm-project/issues/124489>124489</a>
</td>
</tr>
<tr>
<th>Summary</th>
<td>
[Flang] Compilation abnormally terminates when a program uses equivalence, namelist, and read statement
</td>
</tr>
<tr>
<th>Labels</th>
<td>
flang
</td>
</tr>
<tr>
<th>Assignees</th>
<td>
</td>
</tr>
<tr>
<th>Reporter</th>
<td>
ohno-fj
</td>
</tr>
</table>
<pre>
```
Version of flang : 20.0.0(69d3ba3db922fca8cfc47b5f115b6bea6a737aab)/AArch64
```
When a program uses `equivalence`, `namelist`, and `read` statement, a compilation terminates abnormally.
Compilation ends normally in the following cases:
- remove the `equivalue` statement, or
- remove the `read` statement, or
- Change `namelist-group-name (kono1)` specified in the `read` statement to a `array (r1k001)`, or
- Change the number of elements in `array (r1k001)` to 1
The following are the test program, Flang, Gfortran and ifx compilation/execution result.
ioct148_2.f:
```fortran
program main
real r9dim2,rdim
equivalence (r9dim2,rdim)
real*8 r1k001(5)
namelist /kono1/r1k001
read (5,kono1)
print *,'end'
end
```
```
$ flang ioct148_2.f
flang: /work/groups/ssoft/compiler/llvm/src/llvm-main/llvm/include/llvm/Support/Casting.h:662: decltype(auto) llvm::dyn_cast(From*) [with To = mlir::omp::OutlineableOpenMPOpInterface; From = mlir::Operation]: Assertion `detail::isPresent(Val) && "dyn_cast on a non-existent value"' failed.
PLEASE submit a bug report to https://github.com/llvm/llvm-project/issues/ and include the crash backtrace.
Stack dump:
0. Program arguments: /work/groups/ssoft/compiler/llvm/aarch64/main-20250120-69d3ba3db922/bin/flang -fc1 -triple aarch64-unknown-linux-gnu -emit-obj -mrelocation-model pic -pic-level 2 -pic-is-pie -target-cpu generic -target-feature +outline-atomics -target-feature +v8a -target-feature +fp-armv8 -target-feature
+neon -resource-dir /work/groups/ssoft/compiler/llvm/aarch64/main-20250120-69d3ba3db922/lib/clang/20 -mframe-pointer=non-leaf -o /tmp/ioct148_2-0a2fdd.o -x f95-cpp-input ioct148_2.f
#0 0x0000400036aa25a8 llvm::sys::PrintStackTrace(llvm::raw_ostream&, int) (/work/groups/ssoft/compiler/llvm/aarch64/main-latest/lib/libLLVM.so.20.0git+0x5a025a8)
#1 0x0000400036aa0630 llvm::sys::RunSignalHandlers() (/work/groups/ssoft/compiler/llvm/aarch64/main-latest/lib/libLLVM.so.20.0git+0x5a00630)
#2 0x0000400036aa0788 SignalHandler(int) Signals.cpp:0:0
#3 0x0000400026bc07a0 (linux-vdso.so.1+0x7a0)
#4 0x000040003b936274 raise (/lib64/libc.so.6+0x36274)
#5 0x000040003b920a2c abort (/lib64/libc.so.6+0x20a2c)
#6 0x000040003b92fba0 __assert_fail_base (/lib64/libc.so.6+0x2fba0)
#7 0x000040003b92fc18 __assert_perror_fail (/lib64/libc.so.6+0x2fc18)
#8 0x00000000057f4864 fir::ConvertFIRToLLVMPattern::getBlockForAllocaInsert(mlir::Operation*, mlir::Region*) const (/work/groups/ssoft/compiler/llvm/aarch64/main-20250120-69d3ba3db922/bin/flang+0x57f4864)
#9 0x00000000057f476c fir::ConvertFIRToLLVMPattern::getBlockForAllocaInsert(mlir::Operation*, mlir::Region*) const (/work/groups/ssoft/compiler/llvm/aarch64/main-20250120-69d3ba3db922/bin/flang+0x57f476c)
#10 0x00000000057f476c fir::ConvertFIRToLLVMPattern::getBlockForAllocaInsert(mlir::Operation*, mlir::Region*) const (/work/groups/ssoft/compiler/llvm/aarch64/main-20250120-69d3ba3db922/bin/flang+0x57f476c)
#11 0x00000000057e4290 (anonymous namespace)::AllocaOpConversion::matchAndRewrite(fir::AllocaOp, fir::AllocaOpAdaptor, mlir::ConversionPatternRewriter&) const CodeGen.cpp:0:0
#12 0x00000000057e2c04 fir::FIROpConversion<fir::AllocaOp>::matchAndRewrite(mlir::Operation*, llvm::ArrayRef<mlir::ValueRange>, mlir::ConversionPatternRewriter&) const CodeGen.cpp:0:0
#13 0x0000400030e2fce0 mlir::ConversionPattern::matchAndRewrite(mlir::Operation*, mlir::PatternRewriter&) const (/work/groups/ssoft/compiler/llvm/aarch64/main-latest/lib/libMLIR.so.20.0git+0x525fce0)
#14 0x0000400030b9a64c mlir::PatternApplicator::matchAndRewrite(mlir::Operation*, mlir::PatternRewriter&, llvm::function_ref<bool (mlir::Pattern const&)>, llvm::function_ref<void (mlir::Pattern const&)>, llvm::function_ref<llvm::LogicalResult (mlir::Pattern const&)>) (/work/groups/ssoft/compiler/llvm/aarch64/main-la
test/lib/libMLIR.so.20.0git+0x4fca64c)
#15 0x0000400030e32668 (anonymous namespace)::OperationLegalizer::legalize(mlir::Operation*, mlir::ConversionPatternRewriter&) DialectConversion.cpp:0:0
#16 0x0000400030e32bb4 mlir::OperationConverter::convert(mlir::ConversionPatternRewriter&, mlir::Operation*) (/work/groups/ssoft/compiler/llvm/aarch64/main-latest/lib/libMLIR.so.20.0git+0x5262bb4)
#17 0x0000400030e34b4c mlir::OperationConverter::convertOperations(llvm::ArrayRef<mlir::Operation*>) (/work/groups/ssoft/compiler/llvm/aarch64/main-latest/lib/libMLIR.so.20.0git+0x5264b4c)
#18 0x0000400030e3691c mlir::applyFullConversion(mlir::Operation*, mlir::ConversionTarget const&, mlir::FrozenRewritePatternSet const&, mlir::ConversionConfig) (/work/groups/ssoft/compiler/llvm/aarch64/main-latest/lib/libMLIR.so.20.0git+0x526691c)
#19 0x00000000057ca31c (anonymous namespace)::FIRToLLVMLowering::runOnOperation() CodeGen.cpp:0:0
#20 0x0000400030b658b8 mlir::detail::OpToOpPassAdaptor::run(mlir::Pass*, mlir::Operation*, mlir::AnalysisManager, bool, unsigned int) (/work/groups/ssoft/compiler/llvm/aarch64/main-latest/lib/libMLIR.so.20.0git+0x4f958b8)
#21 0x0000400030b65b58 mlir::detail::OpToOpPassAdaptor::runPipeline(mlir::OpPassManager&, mlir::Operation*, mlir::AnalysisManager, bool, unsigned int, mlir::PassInstrumentor*, mlir::PassInstrumentation::PipelineParentInfo const*) (/work/groups/ssoft/compiler/llvm/aarch64/main-latest/lib/libMLIR.so.20.0git+0x4f95b58)
#22 0x0000400030b66460 mlir::PassManager::run(mlir::Operation*) (/work/groups/ssoft/compiler/llvm/aarch64/main-latest/lib/libMLIR.so.20.0git+0x4f96460)
#23 0x0000000004d27d5c Fortran::frontend::CodeGenAction::generateLLVMIR() (/work/groups/ssoft/compiler/llvm/aarch64/main-20250120-69d3ba3db922/bin/flang+0x4d27d5c)
#24 0x0000000004d2a590 Fortran::frontend::CodeGenAction::executeAction() (/work/groups/ssoft/compiler/llvm/aarch64/main-20250120-69d3ba3db922/bin/flang+0x4d2a590)
#25 0x0000000004c395ac Fortran::frontend::FrontendAction::execute() (/work/groups/ssoft/compiler/llvm/aarch64/main-20250120-69d3ba3db922/bin/flang+0x4c395ac)
#26 0x0000000004c2bca4 Fortran::frontend::CompilerInstance::executeAction(Fortran::frontend::FrontendAction&) (/work/groups/ssoft/compiler/llvm/aarch64/main-20250120-69d3ba3db922/bin/flang+0x4c2bca4)
#27 0x0000000004c4085c Fortran::frontend::executeCompilerInvocation(Fortran::frontend::CompilerInstance*) (/work/groups/ssoft/compiler/llvm/aarch64/main-20250120-69d3ba3db922/bin/flang+0x4c4085c)
#28 0x0000000004c24518 fc1_main(llvm::ArrayRef<char const*>, char const*) (/work/groups/ssoft/compiler/llvm/aarch64/main-20250120-69d3ba3db922/bin/flang+0x4c24518)
#29 0x0000000004c23f70 main (/work/groups/ssoft/compiler/llvm/aarch64/main-20250120-69d3ba3db922/bin/flang+0x4c23f70)
#30 0x000040003b924384 __libc_start_main (/lib64/libc.so.6+0x24384)
#31 0x0000000004c2243c _start (/work/groups/ssoft/compiler/llvm/aarch64/main-20250120-69d3ba3db922/bin/flang+0x4c2243c)
flang-20: error: unable to execute command: Aborted (core dumped)
flang-20: error: flang frontend command failed due to signal (use -v to see invocation)
flang version 20.0.0git (https://github.com/llvm/llvm-project.git 69d3ba3db922fca8cfc47b5f115b6bea6a737aab)
Target: aarch64-unknown-linux-gnu
Thread model: posix
InstalledDir: /work/groups/ssoft/compiler/llvm/aarch64/main-20250120-69d3ba3db922/bin
Build config: +assertions
flang-20: note: diagnostic msg:
********************
PLEASE ATTACH THE FOLLOWING FILES TO THE BUG REPORT:
Preprocessed source(s) and associated run script(s) are located at:
flang-20: note: diagnostic msg: /tmp/ioct148_2-2a4c15
flang-20: note: diagnostic msg: /tmp/ioct148_2-2a4c15.sh
flang-20: note: diagnostic msg:
********************
$
```
```
$ cat /tmp/ioct148_2-2a4c15
#line "./ioct148_2.f" 1
program main
real r9dim2,rdim
equivalence (r9dim2,rdim)
real*8 r1k001(5)
namelist /kono1/r1k001
read (5,kono1)
print *,'end'
end
$
```
```
$ cat /tmp/ioct148_2-2a4c15.sh
# Crash reproducer for clang version 20.0.0git (https://github.com/llvm/llvm-project.git 69d3ba3db922fca8cfc47b5f115b6bea6a737aab)
# Driver args: "ioct148_2.f"
# Original command: "/work/groups/ssoft/compiler/llvm/aarch64/main-20250120-69d3ba3db922/bin/flang" "-fc1" "-triple" "aarch64-unknown-linux-gnu" "-emit-obj" "-mrelocation-model" "pic" "-pic-level" "2" "-pic-is-pie" "-target-cpu" "generic" "-target-feature" "+outline-atomics" "-target-feature" "+v8a" "-target-featur
e" "+fp-armv8" "-target-feature" "+neon" "-resource-dir" "/work/groups/ssoft/compiler/llvm/aarch64/main-20250120-69d3ba3db922/lib/clang/20" "-mframe-pointer=non-leaf" "-o" "/tmp/ioct148_2-0a2fdd.o" "-x" "f95-cpp-input" "ioct148_2.f"
"/work/groups/ssoft/compiler/llvm/aarch64/main-20250120-69d3ba3db922/bin/flang" "-fc1" "-triple" "aarch64-unknown-linux-gnu" "-emit-obj" "-mrelocation-model" "pic" "-pic-level" "2" "-pic-is-pie" "-target-cpu" "generic" "-target-feature" "+outline-atomics" "-target-feature" "+v8a" "-target-feature" "+fp-armv8" "-tar
get-feature" "+neon" "-mframe-pointer=non-leaf" "-x" "f95-cpp-input" "ioct148_2-2a4c15"
$
```
```
$ gfortran ioct148_2.f
$
```
```
$ ifx ioct148_2.f
$
```
</pre>
<img width="1" height="1" alt="" src="http://email.email.llvm.org/o/eJzsWltz46iz_zTkhZILo4vlhzwozng2VZmTVCZn_o8phFoOOxLoAMplP_0pkGTJjnPbzGQf_puarbWg1fSvryCaGSM2EuAYxScoPj1irb1V-ljdShWUfx7lqng8Rgnp_5HsB2gjlMSqxGXF5AajMMOUzMiMIJomyyLMWVjkS0pLzlJe8miRx-V8HudJDixhi3DBWI7oEtF1lml-m0SIZNMVEMn-cwsSM9xotdGsxq0Bg1FC4P9acccqkBwcKV25QclqqISx_QiThRvVwAqUEGwss1CDtH4Oc1U3omLWIbCgayGZBYNZLpWuWVU9zjBGJFtNyEAWBg_TWEhsbwGXqqrUvZAbzJkBg0IndYA11OoOPMUobgtPBFH6APlBkXvK1S2TG5jCDTZatU3gHjGi6U8l1dxp1TFogItSQDFIe4g5tgozN8O0Zo-OhZ7_JKTn8XRpx0e2dQ7amR4qz8S4FZ7j4VaYd_a83lEZ0x07C8YONnYLrp0_uR9fS6WtZtIbU5QPU7MhuoYH4K23jQbTVnbWLSIUt_MovaGzsrPH1ql6dohkW5eqmfDP_k8Dq7BeFqKmiK50Iert1MTlPL4dIrp0dO5tRLMUD-DTuJ_xf4PBMKLr3krrnnKyfoG791ZbQ3phhXTvZYiuEF2ALBBdjKLJ4mnk7DzSqI_RqWpI5sdc2CK6vlf6J6Jr70wG0bUxqrSIrjuNg0Z0XVV3tZvRvH8IvPK2E0Lyqi1gHPjeNo3SjsuKGSvkZnaLwixJqFuzAF7ZxwYQTVlrFaJL7F8LMxRmxaO84cxYRNO1VrVHvsQoPrkX9hZfK4zCU1xXQnfkqm66HxetrYQElldw0YD8dnnRnEkLumQcUHiCHbO9dy8a0J1DxadOrswY0N6pUEIKsExUHaEwlxqMD8f0h7P0EiOaIJpgROkgMFYuX0klA3gQxrr46iKfUkQXuGSigsL56eX5l-z7F2zavBYWM5y3G6zBqcuFy621jU8mdO2MIuxtm8-4U8SgW6__Rqs_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