<table border="1" cellspacing="0" cellpadding="8">
<tr>
<th>Issue</th>
<td>
<a href=https://github.com/llvm/llvm-project/issues/96424>96424</a>
</td>
</tr>
<tr>
<th>Summary</th>
<td>
[Flang] llvm-project/flang/lib/Lower/ConvertCall.cpp:775: hlfir::EntityWithAttributes genStmtFunctionRef(mlir::Location, Fortran::lower::AbstractConverter &, Fortran::lower::SymMap &, Fortran::lower::StatementContext &, const Fortran::evaluate::ProcedureRef &): Assertion `expr && "assumed type used as statement function argument"' failed.
</td>
</tr>
<tr>
<th>Labels</th>
<td>
mlir,
flang
</td>
</tr>
<tr>
<th>Assignees</th>
<td>
</td>
</tr>
<tr>
<th>Reporter</th>
<td>
k-arrows
</td>
</tr>
</table>
<pre>
Crash itself is reproducible on Godbolt:
https://godbolt.org/z/GW1heG8KM
Reproducer:
```f90
subroutine s(x)
type(*) :: x
integer :: i
i(x) = 0
print *, i(x)
end subroutine
```
With assertion-enabled flang-new, compiling the reproducer results in the following assertion failure:
```txt
flang-new: /path_to_llvm_project/llvm-project/flang/lib/Lower/ConvertCall.cpp:775: hlfir::EntityWithAttributes genStmtFunctionRef(mlir::Location, Fortran::lower::AbstractConverter &, Fortran::lower::SymMap &, Fortran::lower::StatementContext &, const Fortran::evaluate::ProcedureRef &): Assertion `expr && "assumed type used as statement function argument"' failed.
```
Stack dump:
```console
PLEASE submit a bug report to https://github.com/llvm/llvm-project/issues/ and include the crash backtrace.
Stack dump:
0. Program arguments: /opt/compiler-explorer/clang-llvmflang-trunk-20240623/bin/flang-new -fc1 -triple x86_64-unknown-linux-gnu -S -mrelocation-model pic -pic-level 2 -pic-is-pie -target-cpu x86-64 -mllvm -x86-asm-syntax=intel -resource-dir /opt/compiler-explorer/clang-llvmflang-trunk-20240623/bin/.. -mframe-pointer=all -o /app/output.s -x f95-cpp-input /app/example.f90
#0 0x00000000034d3ff8 llvm::sys::PrintStackTrace(llvm::raw_ostream&, int) (/opt/compiler-explorer/clang-llvmflang-trunk-20240623/bin/flang-new+0x34d3ff8)
#1 0x00000000034d197c SignalHandler(int) Signals.cpp:0:0
#2 0x000070162fc42520 (/lib/x86_64-linux-gnu/libc.so.6+0x42520)
#3 0x0000000003afb591 hlfir::EntityWithAttributes (anonymous namespace)::HlfirBuilder::gen<Fortran::evaluate::SomeType>(Fortran::evaluate::Expr<Fortran::evaluate::SomeType> const&) (.part.0) ConvertExprToHLFIR.cpp:0:0
#4 0x0000000003afb8cb Fortran::lower::convertExprToHLFIR(mlir::Location, Fortran::lower::AbstractConverter&, Fortran::evaluate::Expr<Fortran::evaluate::SomeType> const&, Fortran::lower::SymMap&, Fortran::lower::StatementContext&) (/opt/compiler-explorer/clang-llvmflang-trunk-20240623/bin/flang-new+0x3afb8cb)
#5 0x000000000391ba6c genProcedureRef((anonymous namespace)::CallContext&) ConvertCall.cpp:0:0
#6 0x000000000391e244 Fortran::lower::convertCallToHLFIR(mlir::Location, Fortran::lower::AbstractConverter&, Fortran::evaluate::ProcedureRef const&, std::optional<mlir::Type>, Fortran::lower::SymMap&, Fortran::lower::StatementContext&) (/opt/compiler-explorer/clang-llvmflang-trunk-20240623/bin/flang-new+0x391e244)
#7 0x0000000003aeebb0 hlfir::EntityWithAttributes (anonymous namespace)::HlfirBuilder::gen<Fortran::evaluate::Type<(Fortran::common::TypeCategory)0, 4>>(Fortran::evaluate::Expr<Fortran::evaluate::Type<(Fortran::common::TypeCategory)0, 4>> const&) ConvertExprToHLFIR.cpp:0:0
#8 0x0000000003ace4a0 hlfir::EntityWithAttributes (anonymous namespace)::HlfirBuilder::gen<Fortran::evaluate::SomeKind<(Fortran::common::TypeCategory)0>>(Fortran::evaluate::Expr<Fortran::evaluate::SomeKind<(Fortran::common::TypeCategory)0>> const&) ConvertExprToHLFIR.cpp:0:0
#9 0x0000000003afb6dd hlfir::EntityWithAttributes (anonymous namespace)::HlfirBuilder::gen<Fortran::evaluate::SomeType>(Fortran::evaluate::Expr<Fortran::evaluate::SomeType> const&) (.part.0) ConvertExprToHLFIR.cpp:0:0
#10 0x0000000003afb95d Fortran::lower::convertExprToValue(mlir::Location, Fortran::lower::AbstractConverter&, Fortran::evaluate::Expr<Fortran::evaluate::SomeType> const&, Fortran::lower::SymMap&, Fortran::lower::StatementContext&) (/opt/compiler-explorer/clang-llvmflang-trunk-20240623/bin/flang-new+0x3afb95d)
#11 0x000000000387da95 (anonymous namespace)::FirConverter::genExprValue(Fortran::evaluate::Expr<Fortran::evaluate::SomeType> const&, Fortran::lower::StatementContext&, mlir::Location*) Bridge.cpp:0:0
#12 0x0000000003b57ae7 genOutputItemList(Fortran::lower::AbstractConverter&, mlir::Value, std::__cxx11::list<Fortran::parser::OutputItem, std::allocator<Fortran::parser::OutputItem>> const&, bool, bool, mlir::Value&, bool) IO.cpp:0:0
#13 0x0000000003b5e2c1 mlir::Value genDataTransferStmt<false, false, Fortran::parser::PrintStmt>(Fortran::lower::AbstractConverter&, Fortran::parser::PrintStmt const&) IO.cpp:0:0
#14 0x00000000038ef0bb (anonymous namespace)::FirConverter::genFIR(Fortran::lower::pft::Evaluation&, bool) (.constprop.0) Bridge.cpp:0:0
#15 0x00000000038f2e6c (anonymous namespace)::FirConverter::lowerFunc(Fortran::lower::pft::FunctionLikeUnit&) Bridge.cpp:0:0
#16 0x00000000038f4c9c Fortran::lower::LoweringBridge::lower(Fortran::parser::Program const&, Fortran::semantics::SemanticsContext const&) (/opt/compiler-explorer/clang-llvmflang-trunk-20240623/bin/flang-new+0x38f4c9c)
#17 0x000000000385b3f9 Fortran::frontend::CodeGenAction::beginSourceFileAction() (/opt/compiler-explorer/clang-llvmflang-trunk-20240623/bin/flang-new+0x385b3f9)
#18 0x000000000352ada5 Fortran::frontend::FrontendAction::beginSourceFile(Fortran::frontend::CompilerInstance&, Fortran::frontend::FrontendInputFile const&) (/opt/compiler-explorer/clang-llvmflang-trunk-20240623/bin/flang-new+0x352ada5)
#19 0x000000000351a807 Fortran::frontend::CompilerInstance::executeAction(Fortran::frontend::FrontendAction&) (/opt/compiler-explorer/clang-llvmflang-trunk-20240623/bin/flang-new+0x351a807)
#20 0x0000000003530ded Fortran::frontend::executeCompilerInvocation(Fortran::frontend::CompilerInstance*) (/opt/compiler-explorer/clang-llvmflang-trunk-20240623/bin/flang-new+0x3530ded)
#21 0x0000000001c3a088 fc1_main(llvm::ArrayRef<char const*>, char const*) (/opt/compiler-explorer/clang-llvmflang-trunk-20240623/bin/flang-new+0x1c3a088)
#22 0x0000000001b22244 main (/opt/compiler-explorer/clang-llvmflang-trunk-20240623/bin/flang-new+0x1b22244)
#23 0x000070162fc29d90 (/lib/x86_64-linux-gnu/libc.so.6+0x29d90)
#24 0x000070162fc29e40 __libc_start_main (/lib/x86_64-linux-gnu/libc.so.6+0x29e40)
#25 0x0000000001c38fee _start (/opt/compiler-explorer/clang-llvmflang-trunk-20240623/bin/flang-new+0x1c38fee)
flang-new: error: unable to execute command: Segmentation fault (core dumped)
flang-new: error: flang frontend command failed due to signal (use -v to see invocation)
flang-new version 19.0.0git (https://github.com/llvm/llvm-project.git f73ac218a666e2017565f2210b47332ddcf55f00)
Target: x86_64-unknown-linux-gnu
Thread model: posix
InstalledDir: /opt/compiler-explorer/clang-llvmflang-trunk-20240623/bin
```
</pre>
<img width="1px" height="1px" alt="" src="http://email.email.llvm.org/o/eJzsWl1z3KjS_jX4htKUhD5GuvDFZJzJptZbuxXnffdyCqHWDMcIVIDs8fn1p0CaD8n2xE7s7DlV2dokFoLup59-aBCYGsM3EuASpR9QenVBO7tV-vI2oFqre3NRqurhcqmp2WJuDYgac4M1tFpVHeOlAKwk_qSqUgmL4gUKr1C42FrbGvdEVoisNv3bmdIbRFb_RmT16e9oC5_y3__ou_d_fxmMgj7YQVnY_18XYd9iulKrznIJ2CCS7xAp-hcY24cWEMkRWSBSYGcjXuDd_i2XFjag9-380D5YwSi-wuG-tdVcWuxNLQ9d-pcgK3xEMcF5Gs_f3G4xNQa05UoGIGkpoMK1oHITSLh3pplqWi643GC7hQOtoLEG0wlrMJf-Ta2EUPeu38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