<table border="1" cellspacing="0" cellpadding="8">
<tr>
<th>Issue</th>
<td>
<a href=https://github.com/llvm/llvm-project/issues/63364>63364</a>
</td>
</tr>
<tr>
<th>Summary</th>
<td>
[flang] Assertion `!fir::isa_derived(toTy)' failed.
</td>
</tr>
<tr>
<th>Labels</th>
<td>
new issue
</td>
</tr>
<tr>
<th>Assignees</th>
<td>
</td>
</tr>
<tr>
<th>Reporter</th>
<td>
k-arrows
</td>
</tr>
</table>
<pre>
Crashed by the following test program:
https://github.com/llvm/llvm-test-suite/blob/main/Fortran/gfortran/regression/pr68227.f90
```console
$ cat pr68227.f90
program p
type t
end type
type t2
type(t), pointer :: a
end type
type(t), target :: x
type(t2), pointer :: y(:)
integer :: i
integer :: n = 2
allocate (y(n))
forall (i=1:n) y(i)%a = x
end program p
```
Stack dump:
```console
#0 0x000055561c740584 llvm::sys::PrintStackTrace(llvm::raw_ostream&, int)
#1 0x000055561c740bd4 SignalHandler(int) Signals.cpp:0:0
#2 0x00007f94b7a03520 (/lib/x86_64-linux-gnu/libc.so.6+0x42520)
#3 0x00007f94b7a57a7c __pthread_kill_implementation ./nptl/pthread_kill.c:44:76
#4 0x00007f94b7a57a7c __pthread_kill_internal ./nptl/pthread_kill.c:78:10
#5 0x00007f94b7a57a7c pthread_kill ./nptl/pthread_kill.c:89:10
#6 0x00007f94b7a03476 gsignal ./signal/../sysdeps/posix/raise.c:27:6
#7 0x00007f94b79e97f3 abort ./stdlib/abort.c:81:7
#8 0x00007f94b79e971b _nl_load_domain ./intl/loadmsgcat.c:1177:9
#9 0x00007f94b79fae96 (/lib/x86_64-linux-gnu/libc.so.6+0x39e96)
#10 0x000055561d44ee40 fir::FirOpBuilder::createConvert(mlir::Location, mlir::Type, mlir::Value)
#11 0x000055561c9cac6f (anonymous namespace)::ArrayExprLowering::convertElementForUpdate(mlir::Location, mlir::Type, mlir::Value) ConvertExpr.cpp:0:0
#12 0x000055561c9f18d5 std::_Function_handler<fir::ExtendedValue (Fortran::lower::IterationSpace const&), (anonymous namespace)::ArrayExprLowering::applyPathToArrayLoad(fir::ArrayLoadOp, Fortran::lower::ComponentPath&)::'lambda1'(Fortran::lower::IterationSpace const&)>::_M_invoke(std::_Any_data const&, Fortran::lower::IterationSpace const&) ConvertExpr.cpp:0:0
#13 0x000055561c98ac93 (anonymous namespace)::ArrayExprLowering::lowerScalarAssignment(Fortran::evaluate::Expr<Fortran::evaluate::SomeType> const&, Fortran::evaluate::Expr<Fortran::evaluate::SomeType> const&) ConvertExpr.cpp:0:0
#14 0x000055561c9857c5 Fortran::lower::createAnyMaskedArrayAssignment(Fortran::lower::AbstractConverter&, Fortran::evaluate::Expr<Fortran::evaluate::SomeType> const&, Fortran::evaluate::Expr<Fortran::evaluate::SomeType> const&, Fortran::lower::ExplicitIterSpace&, Fortran::lower::ImplicitIterSpace&, Fortran::lower::SymMap&, Fortran::lower::StatementContext&)
#15 0x000055561c94565e (anonymous namespace)::FirConverter::genArrayAssignment(Fortran::evaluate::Assignment const&, Fortran::lower::StatementContext&, std::optional<llvm::SmallVector<mlir::Value, 6u>>, std::optional<llvm::SmallVector<mlir::Value, 6u>>) Bridge.cpp:0:0
#16 0x000055561c951f4a std::__detail::__variant::__gen_vtable_impl<std::__detail::__variant::_Multi_array<std::__detail::__variant::__deduce_visit_result<void> (*)(Fortran::common::visitors<(anonymous namespace)::FirConverter::genAssignment(Fortran::evaluate::Assignment const&)::'lambda0'(Fortran::evaluate::Assignment::Intrinsic const&), (anonymous namespace)::FirConverter::genAssignment(Fortran::evaluate::Assignment const&)::'lambda0'(Fortran::evaluate::ProcedureRef const&), (anonymous namespace)::FirConverter::genAssignment(Fortran::evaluate::Assignment const&)::'lambda0'(std::vector<Fortran::evaluate::Expr<Fortran::evaluate::Type<(Fortran::common::TypeCategory)0, 8>>, std::allocator<Fortran::evaluate::Expr<Fortran::evaluate::Type<(Fortran::common::TypeCategory)0, 8>>>> const&), (anonymous namespace)::FirConverter::genAssignment(Fortran::evaluate::Assignment const&)::'lambda0'(std::vector<std::pair<Fortran::evaluate::Expr<Fortran::evaluate::Type<(Fortran::common::TypeCategory)0, 8>>, Fortran::evaluate::Expr<Fortran::evaluate::Type<(Fortran::common::TypeCategory)0, 8>>>, std::allocator<std::pair<Fortran::evaluate::Expr<Fortran::evaluate::Type<(Fortran::common::TypeCategory)0, 8>>, Fortran::evaluate::Expr<Fortran::evaluate::Type<(Fortran::common::TypeCategory)0, 8>>>>> const&)>&&, std::variant<Fortran::evaluate::Assignment::Intrinsic, Fortran::evaluate::ProcedureRef, std::vector<Fortran::evaluate::Expr<Fortran::evaluate::Type<(Fortran::common::TypeCategory)0, 8>>, std::allocator<Fortran::evaluate::Expr<Fortran::evaluate::Type<(Fortran::common::TypeCategory)0, 8>>>>, std::vector<std::pair<Fortran::evaluate::Expr<Fortran::evaluate::Type<(Fortran::common::TypeCategory)0, 8>>, Fortran::evaluate::Expr<Fortran::evaluate::Type<(Fortran::common::TypeCategory)0, 8>>>, std::allocator<std::pair<Fortran::evaluate::Expr<Fortran::evaluate::Type<(Fortran::common::TypeCategory)0, 8>>, Fortran::evaluate::Expr<Fortran::evaluate::Type<(Fortran::common::TypeCategory)0, 8>>>>>> const&)>, std::integer_sequence<unsigned long, 0ul>>::__visit_invoke(Fortran::common::visitors<(anonymous namespace)::FirConverter::genAssignment(Fortran::evaluate::Assignment const&)::'lambda0'(Fortran::evaluate::Assignment::Intrinsic const&), (anonymous namespace)::FirConverter::genAssignment(Fortran::evaluate::Assignment const&)::'lambda0'(Fortran::evaluate::ProcedureRef const&), (anonymous namespace)::FirConverter::genAssignment(Fortran::evaluate::Assignment const&)::'lambda0'(std::vector<Fortran::evaluate::Expr<Fortran::evaluate::Type<(Fortran::common::TypeCategory)0, 8>>, std::allocator<Fortran::evaluate::Expr<Fortran::evaluate::Type<(Fortran::common::TypeCategory)0, 8>>>> const&), (anonymous namespace)::FirConverter::genAssignment(Fortran::evaluate::Assignment const&)::'lambda0'(std::vector<std::pair<Fortran::evaluate::Expr<Fortran::evaluate::Type<(Fortran::common::TypeCategory)0, 8>>, Fortran::evaluate::Expr<Fortran::evaluate::Type<(Fortran::common::TypeCategory)0, 8>>>, std::allocator<std::pair<Fortran::evaluate::Expr<Fortran::evaluate::Type<(Fortran::common::TypeCategory)0, 8>>, Fortran::evaluate::Expr<Fortran::evaluate::Type<(Fortran::common::TypeCategory)0, 8>>>>> const&)>&&, std::variant<Fortran::evaluate::Assignment::Intrinsic, Fortran::evaluate::ProcedureRef, std::vector<Fortran::evaluate::Expr<Fortran::evaluate::Type<(Fortran::common::TypeCategory)0, 8>>, std::allocator<Fortran::evaluate::Expr<Fortran::evaluate::Type<(Fortran::common::TypeCategory)0, 8>>>>, std::vector<std::pair<Fortran::evaluate::Expr<Fortran::evaluate::Type<(Fortran::common::TypeCategory)0, 8>>, Fortran::evaluate::Expr<Fortran::evaluate::Type<(Fortran::common::TypeCategory)0, 8>>>, std::allocator<std::pair<Fortran::evaluate::Expr<Fortran::evaluate::Type<(Fortran::common::TypeCategory)0, 8>>, Fortran::evaluate::Expr<Fortran::evaluate::Type<(Fortran::common::TypeCategory)0, 8>>>>>> const&) Bridge.cpp:0:0
#17 0x000055561c9426c7 (anonymous namespace)::FirConverter::genAssignment(Fortran::evaluate::Assignment const&) Bridge.cpp:0:0
#18 0x000055561c95d113 (anonymous namespace)::FirConverter::genFIR(Fortran::parser::ForallStmt const&) Bridge.cpp:0:0
#19 0x000055561c93b3d9 (anonymous namespace)::FirConverter::genFIR(Fortran::lower::pft::Evaluation&, bool) Bridge.cpp:0:0
#20 0x000055561c969d7c (anonymous namespace)::FirConverter::lowerFunc(Fortran::lower::pft::FunctionLikeUnit&) Bridge.cpp:0:0
#21 0x000055561c91ce37 Fortran::lower::LoweringBridge::lower(Fortran::parser::Program const&, Fortran::semantics::SemanticsContext const&)
#22 0x000055561c885b7c Fortran::frontend::CodeGenAction::beginSourceFileAction()
#23 0x000055561c760b99 Fortran::frontend::FrontendAction::beginSourceFile(Fortran::frontend::CompilerInstance&, Fortran::frontend::FrontendInputFile const&)
#24 0x000055561c7591e8 Fortran::frontend::CompilerInstance::executeAction(Fortran::frontend::FrontendAction&)
#25 0x000055561c7637b6 Fortran::frontend::executeCompilerInvocation(Fortran::frontend::CompilerInstance*)
#26 0x000055561b7db824 fc1_main(llvm::ArrayRef<char const*>, char const*)
#27 0x000055561b7d99d2 main
#28 0x00007f94b79ead90 __libc_start_call_main ./csu/../sysdeps/nptl/libc_start_call_main.h:58:16
#29 0x00007f94b79eae40 call_init ./csu/../csu/libc-start.c:128:20
#30 0x00007f94b79eae40 __libc_start_main ./csu/../csu/libc-start.c:379:5
#31 0x000055561b7d8e35 _start
flang-new: error: unable to execute command: Aborted
flang-new: error: flang frontend command failed due to signal (use -v to see invocation)
flang-new version 17.0.0 (https://github.com/llvm/llvm-project.git 64083172eea26e50c8b22b85697a825be8bda424)
Target: x86_64-unknown-linux-gnu
Thread model: posix
```
The crash above is the result of using flang-new, which I built recently. Here is the result of LLVM 16.0.4.
```console
$ flang-new -c pr68227.f90
error: loc("./pr68227.f90":16:4): 'fir.convert' op invalid type conversion
error: verification of lowering to FIR failed
```
</pre>
<img width="1px" height="1px" alt="" src="http://email.email.llvm.org/o/eJzsWl1z27bS_jX0DcYaCvy-8IWiWG8zk0wzddpbDggsJbwGAR4AlK1_fwYg9UFGkp2kPU3P8UzakODi2d1nFwtEWGIMX0uAuyB5FyTvb0hnN0rfPd4SrdWTuakU290tNTEbYKjaIbsBVCsh1BOXa2TBWNRqtdakCaJFEL4PwsXG2ta4N7wK8GrN7aarZlQ1AV4Jsd3_devm3pqOWwjwqhKqCvCqIVwGeLVS2mrintb14VHDWoMxXLmXVqc5xtmsLsJeaZCG_R-qpFEChlEcI0qciRPxwWbUDnL-_wghu2sB2cMrSOaHzkrhw_swFODcBrgI8BK1iksLGjkaogUir0E8mW6JXoPdz37-SgyfV7MLcO6JLw4z3Pf1UYJf-iBREL1HeGIWEUJRYgEFOHfg0us9otdKEyHcVx5E7-dBt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