Issue |
144670
|
Summary |
[Flang] Crash with nested types
|
Labels |
flang
|
Assignees |
|
Reporter |
k-arrows
|
Reproducer:
https://godbolt.org/z/7vY3YEhjK
```f90
type t1(i)
integer, kind :: i
integer(kind=i) :: j
end type
type t2(i)
integer, kind :: i
type(t1(i)) :: s1 = t1(2)(2)
end type
type t3
type(t2(2)) :: s2 = t2(2)(t1(2)(2))
end type
end
```
Backtrace:
```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-20250618/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-20250618/lib/clang/21 -mframe-pointer=all -o /app/output.s -x f95 /app/example.f90
#0 0x0000000003e6ece8 llvm::sys::PrintStackTrace(llvm::raw_ostream&, int) (/opt/compiler-explorer/clang-llvmflang-trunk-20250618/bin/flang+0x3e6ece8)
#1 0x0000000003e6c8a4 SignalHandler(int, siginfo_t*, void*) Signals.cpp:0:0
#2 0x00007b5635642520 (/lib/x86_64-linux-gnu/libc.so.6+0x42520)
#3 0x00007b56356969fc pthread_kill (/lib/x86_64-linux-gnu/libc.so.6+0x969fc)
#4 0x00007b5635642476 gsignal (/lib/x86_64-linux-gnu/libc.so.6+0x42476)
#5 0x00007b56356287f3 abort (/lib/x86_64-linux-gnu/libc.so.6+0x287f3)
#6 0x0000000002087df1 Fortran::lower::translateVariableToFIRType(Fortran::lower::AbstractConverter&, Fortran::lower::pft::Variable const&) (.cold) ConvertType.cpp:0:0
#7 0x00000000045804f5 (anonymous namespace)::TypeBuilderImpl::genDerivedType(Fortran::semantics::DerivedTypeSpec const&) ConvertType.cpp:0:0
#8 0x0000000004581cc5 Fortran::lower::translateDerivedTypeToFIRType(Fortran::lower::AbstractConverter&, Fortran::semantics::DerivedTypeSpec const&) (/opt/compiler-explorer/clang-llvmflang-trunk-20250618/bin/flang+0x4581cc5)
#9 0x00000000047a99c7 Fortran::lower::genInlinedStructureCtorLit(Fortran::lower::AbstractConverter&, mlir::Location, Fortran::evaluate::StructureConstructor const&) (/opt/compiler-explorer/clang-llvmflang-trunk-20250618/bin/flang+0x47a99c7)
#10 0x00000000043f4f96 (anonymous namespace)::ScalarExprLowering::genval(Fortran::evaluate::StructureConstructor const&) ConvertExpr.cpp:0:0
#11 0x00000000043f5e28 (anonymous namespace)::ScalarExprLowering::genval(Fortran::evaluate::Constant<Fortran::evaluate::SomeKind<(Fortran::common::TypeCategory)6>> const&) ConvertExpr.cpp:0:0
#12 0x00000000043f60b5 fir::ExtendedValue (anonymous namespace)::ScalarExprLowering::genval<Fortran::evaluate::SomeKind<(Fortran::common::TypeCategory)6>>(Fortran::evaluate::Expr<Fortran::evaluate::SomeKind<(Fortran::common::TypeCategory)6>> const&) ConvertExpr.cpp:0:0
#13 0x00000000043f65d8 fir::ExtendedValue (anonymous namespace)::ScalarExprLowering::genval<Fortran::evaluate::SomeType>(Fortran::evaluate::Expr<Fortran::evaluate::SomeType> const&) ConvertExpr.cpp:0:0
#14 0x000000000449fb3b Fortran::lower::createSomeInitializerExpression(mlir::Location, Fortran::lower::AbstractConverter&, Fortran::evaluate::Expr<Fortran::evaluate::SomeType> const&, Fortran::lower::SymMap&, Fortran::lower::StatementContext&) (/opt/compiler-explorer/clang-llvmflang-trunk-20250618/bin/flang+0x449fb3b)
#15 0x00000000045a91c7 genInitializerExprValue(Fortran::lower::AbstractConverter&, mlir::Location, Fortran::evaluate::Expr<Fortran::evaluate::SomeType> const&, Fortran::lower::StatementContext&) ConvertVariable.cpp:0:0
#16 0x00000000045a9f67 Fortran::lower::defineGlobal(Fortran::lower::AbstractConverter&, Fortran::lower::pft::Variable const&, llvm::StringRef, mlir::StringAttr, cuf::DataAttributeAttr)::'lambda1'(fir::FirOpBuilder&)::operator()(fir::FirOpBuilder&) const ConvertVariable.cpp:0:0
#17 0x000000000459b652 createGlobalInitialization(fir::FirOpBuilder&, fir::GlobalOp, std::function<void (fir::FirOpBuilder&)>) ConvertVariable.cpp:0:0
#18 0x000000000459c61f Fortran::lower::defineGlobal(Fortran::lower::AbstractConverter&, Fortran::lower::pft::Variable const&, llvm::StringRef, mlir::StringAttr, cuf::DataAttributeAttr) (/opt/compiler-explorer/clang-llvmflang-trunk-20250618/bin/flang+0x459c61f)
#19 0x00000000045b0380 Fortran::lower::instantiateVariable(Fortran::lower::AbstractConverter&, Fortran::lower::pft::Variable const&, Fortran::lower::SymMap&, llvm::DenseMap<std::tuple<Fortran::semantics::Scope const*, unsigned long>, mlir::Value, llvm::DenseMapInfo<std::tuple<Fortran::semantics::Scope const*, unsigned long>, void>, llvm::detail::DenseMapPair<std::tuple<Fortran::semantics::Scope const*, unsigned long>, mlir::Value>>&) (/opt/compiler-explorer/clang-llvmflang-trunk-20250618/bin/flang+0x45b0380)
#20 0x00000000042e4fcf (anonymous namespace)::FirConverter::startNewFunction(Fortran::lower::pft::FunctionLikeUnit&) Bridge.cpp:0:0
#21 0x0000000004301128 (anonymous namespace)::FirConverter::lowerFunc(Fortran::lower::pft::FunctionLikeUnit&) Bridge.cpp:0:0
#22 0x00000000043032c4 Fortran::lower::LoweringBridge::lower(Fortran::parser::Program const&, Fortran::semantics::SemanticsContext const&) (/opt/compiler-explorer/clang-llvmflang-trunk-20250618/bin/flang+0x43032c4)
#23 0x000000000417b166 Fortran::frontend::CodeGenAction::beginSourceFileAction() (/opt/compiler-explorer/clang-llvmflang-trunk-20250618/bin/flang+0x417b166)
#24 0x0000000003ec5d55 Fortran::frontend::FrontendAction::beginSourceFile(Fortran::frontend::CompilerInstance&, Fortran::frontend::FrontendInputFile const&) (/opt/compiler-explorer/clang-llvmflang-trunk-20250618/bin/flang+0x3ec5d55)
#25 0x0000000003eb4687 Fortran::frontend::CompilerInstance::executeAction(Fortran::frontend::FrontendAction&) (/opt/compiler-explorer/clang-llvmflang-trunk-20250618/bin/flang+0x3eb4687)
#26 0x0000000003ecfeb3 Fortran::frontend::executeCompilerInvocation(Fortran::frontend::CompilerInstance*) (/opt/compiler-explorer/clang-llvmflang-trunk-20250618/bin/flang+0x3ecfeb3)
#27 0x00000000022134ba fc1_main(llvm::ArrayRef<char const*>, char const*) (/opt/compiler-explorer/clang-llvmflang-trunk-20250618/bin/flang+0x22134ba)
#28 0x00000000020c2906 main (/opt/compiler-explorer/clang-llvmflang-trunk-20250618/bin/flang+0x20c2906)
#29 0x00007b5635629d90 (/lib/x86_64-linux-gnu/libc.so.6+0x29d90)
#30 0x00007b5635629e40 __libc_start_main (/lib/x86_64-linux-gnu/libc.so.6+0x29e40)
#31 0x0000000002211e85 _start (/opt/compiler-explorer/clang-llvmflang-trunk-20250618/bin/flang+0x2211e85)
flang-21: error: unable to execute command: Aborted (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 99e263228f4513c166f20469968b2b646edaaa33)
Target: x86_64-unknown-linux-gnu
Thread model: posix
InstalledDir: /opt/compiler-explorer/clang-llvmflang-trunk-20250618/bin
flang-21: note: diagnostic msg:
```
_______________________________________________
llvm-bugs mailing list
llvm-bugs@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-bugs