Open
Description
Reproducer:
https://godbolt.org/z/d7zbEcnYb
module m
integer :: i
contains
elemental function f(c)
character(i) f
character(*), intent(in) :: c
end
elemental subroutine s(c)
character(*), intent(in) :: c
end
end
use m
integer, allocatable :: j(:)
character, dimension(:), pointer :: c1
call s(f(c1(j)))
end
Backtrace:
/app/example.f90:4:24: warning: Function result is never defined
elemental function f(c)
^
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-20250621/bin/flang -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-20250621/lib/clang/21 -mframe-pointer=all -o /app/output.s -x f95 /app/example.f90
#0 0x0000000003e736b8 llvm::sys::PrintStackTrace(llvm::raw_ostream&, int) (/opt/compiler-explorer/clang-llvmflang-trunk-20250621/bin/flang+0x3e736b8)
#1 0x0000000003e71274 SignalHandler(int, siginfo_t*, void*) Signals.cpp:0:0
#2 0x0000795422e42520 (/lib/x86_64-linux-gnu/libc.so.6+0x42520)
#3 0x000000000431e028 Fortran::lower::PreparedActualArgument::getActual(mlir::Location, fir::FirOpBuilder&) const (/opt/compiler-explorer/clang-llvmflang-trunk-20250621/bin/flang+0x431e028)
#4 0x0000000004320a2f preparePresentUserCallActualArgument(mlir::Location, fir::FirOpBuilder&, Fortran::lower::PreparedActualArgument const&, mlir::Type, Fortran::lower::CallInterface<Fortran::lower::CallerInterface>::PassedEntity const&, (anonymous namespace)::CallContext&) ConvertCall.cpp:0:0
#5 0x0000000004326919 prepareUserCallArguments(llvm::SmallVector<std::optional<Fortran::lower::PreparedActualArgument>, 1u>&, Fortran::lower::CallerInterface&, mlir::FunctionType, (anonymous namespace)::CallContext&, llvm::SmallVector<(anonymous namespace)::CallCleanUp, 1u>&) ConvertCall.cpp:0:0
#6 0x0000000004330d31 genProcedureRef((anonymous namespace)::CallContext&) ConvertCall.cpp:0:0
#7 0x0000000004331aa4 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-20250621/bin/flang+0x4331aa4)
#8 0x000000000454d18d hlfir::EntityWithAttributes (anonymous namespace)::HlfirBuilder::gen<Fortran::evaluate::Type<(Fortran::common::TypeCategory)4, 1>>(Fortran::evaluate::Expr<Fortran::evaluate::Type<(Fortran::common::TypeCategory)4, 1>> const&) ConvertExprToHLFIR.cpp:0:0
#9 0x000000000454da33 hlfir::EntityWithAttributes (anonymous namespace)::HlfirBuilder::gen<Fortran::evaluate::SomeKind<(Fortran::common::TypeCategory)4>>(Fortran::evaluate::Expr<Fortran::evaluate::SomeKind<(Fortran::common::TypeCategory)4>> const&) ConvertExprToHLFIR.cpp:0:0
#10 0x0000000004578135 hlfir::EntityWithAttributes (anonymous namespace)::HlfirBuilder::gen<Fortran::evaluate::SomeType>(Fortran::evaluate::Expr<Fortran::evaluate::SomeType> const&) (.part.0) ConvertExprToHLFIR.cpp:0:0
#11 0x0000000004578415 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-20250621/bin/flang+0x4578415)
#12 0x000000000432fbc7 genProcedureRef((anonymous namespace)::CallContext&) ConvertCall.cpp:0:0
#13 0x0000000004331aa4 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-20250621/bin/flang+0x4331aa4)
#14 0x00000000043049fb (anonymous namespace)::FirConverter::genFIR(Fortran::lower::pft::Evaluation&, bool) (.constprop.0) Bridge.cpp:0:0
#15 0x000000000430961c (anonymous namespace)::FirConverter::lowerFunc(Fortran::lower::pft::FunctionLikeUnit&) Bridge.cpp:0:0
#16 0x000000000430b794 Fortran::lower::LoweringBridge::lower(Fortran::parser::Program const&, Fortran::semantics::SemanticsContext const&) (/opt/compiler-explorer/clang-llvmflang-trunk-20250621/bin/flang+0x430b794)
#17 0x0000000004183646 Fortran::frontend::CodeGenAction::beginSourceFileAction() (/opt/compiler-explorer/clang-llvmflang-trunk-20250621/bin/flang+0x4183646)
#18 0x0000000003ecb3c5 Fortran::frontend::FrontendAction::beginSourceFile(Fortran::frontend::CompilerInstance&, Fortran::frontend::FrontendInputFile const&) (/opt/compiler-explorer/clang-llvmflang-trunk-20250621/bin/flang+0x3ecb3c5)
#19 0x0000000003eb9eb7 Fortran::frontend::CompilerInstance::executeAction(Fortran::frontend::FrontendAction&) (/opt/compiler-explorer/clang-llvmflang-trunk-20250621/bin/flang+0x3eb9eb7)
#20 0x0000000003ed5523 Fortran::frontend::executeCompilerInvocation(Fortran::frontend::CompilerInstance*) (/opt/compiler-explorer/clang-llvmflang-trunk-20250621/bin/flang+0x3ed5523)
#21 0x0000000002216b4a fc1_main(llvm::ArrayRef<char const*>, char const*) (/opt/compiler-explorer/clang-llvmflang-trunk-20250621/bin/flang+0x2216b4a)
#22 0x00000000020c5856 main (/opt/compiler-explorer/clang-llvmflang-trunk-20250621/bin/flang+0x20c5856)
#23 0x0000795422e29d90 (/lib/x86_64-linux-gnu/libc.so.6+0x29d90)
#24 0x0000795422e29e40 __libc_start_main (/lib/x86_64-linux-gnu/libc.so.6+0x29e40)
#25 0x0000000002215515 _start (/opt/compiler-explorer/clang-llvmflang-trunk-20250621/bin/flang+0x2215515)
flang-21: error: unable to execute command: Segmentation fault (core dumped)
flang-21: error: flang frontend command failed due to signal (use -v to see invocation)
flang version 21.0.0git (https://github.com/llvm/llvm-project.git 2dfcc4375faa5e3692bd82a022d33bdd6fe55f10)
Target: x86_64-unknown-linux-gnu
Thread model: posix
InstalledDir: /opt/compiler-explorer/clang-llvmflang-trunk-20250621/bin
flang-21: note: diagnostic msg: