<table border="1" cellspacing="0" cellpadding="8">
<tr>
<th>Issue</th>
<td>
<a href=https://github.com/llvm/llvm-project/issues/82886>82886</a>
</td>
</tr>
<tr>
<th>Summary</th>
<td>
[Flang][HLFIR] Assertion `sliceFields.empty() && substring.empty()' failed.
</td>
</tr>
<tr>
<th>Labels</th>
<td>
flang
</td>
</tr>
<tr>
<th>Assignees</th>
<td>
</td>
</tr>
<tr>
<th>Reporter</th>
<td>
k-arrows
</td>
</tr>
</table>
<pre>
Reproducer (`flang-new -c -flang-experimental-polymorphism test.f90`)
```console
$ cat test.f90
program test
implicit none
class(*),pointer :: p(:)
character(len=2),target:: c(2)=['ab','cd']
p=>c
select type(p)
type is(character(*))
associate(x=>p(1:2))
end associate
class default
error stop 1
end select
end
```
Assertion failure
```
flang-new: /path_to_llvm_project/llvm-project/flang/lib/Optimizer/HLFIR/Transforms/ConvertToFIR.cpp:583: virtual mlir::LogicalResult (anonymous namespace)::DesignateOpConversion::matchAndRewrite(hlfir::DesignateOp, mlir::PatternRewriter &) const: Assertion `sliceFields.empty() && substring.empty()' failed.
```
Stack dump
```console
#0 0x0000562f1ed7d27f llvm::sys::PrintStackTrace(llvm::raw_ostream&, int)
#1 0x0000562f1ed7d8b3 SignalHandler(int) Signals.cpp:0:0
#2 0x00007fa7c2481520 (/lib/x86_64-linux-gnu/libc.so.6+0x42520)
#3 0x00007fa7c24d5a7c __pthread_kill_implementation ./nptl/pthread_kill.c:44:76
#4 0x00007fa7c24d5a7c __pthread_kill_internal ./nptl/pthread_kill.c:78:10
#5 0x00007fa7c24d5a7c pthread_kill ./nptl/pthread_kill.c:89:10
#6 0x00007fa7c2481476 gsignal ./signal/../sysdeps/posix/raise.c:27:6
#7 0x00007fa7c24677f3 abort ./stdlib/abort.c:81:7
#8 0x00007fa7c246771b _nl_load_domain ./intl/loadmsgcat.c:1177:9
#9 0x00007fa7c2478e96 (/lib/x86_64-linux-gnu/libc.so.6+0x39e96)
#10 0x0000562f1fd82757 (anonymous namespace)::DesignateOpConversion::matchAndRewrite(hlfir::DesignateOp, mlir::PatternRewriter&) const ConvertToFIR.cpp:0:0
#11 0x0000562f20513391 void llvm::function_ref<void ()>::callback_fn<mlir::PatternApplicator::matchAndRewrite(mlir::Operation*, mlir::PatternRewriter&, llvm::function_ref<bool (mlir::Pattern const&)>, llvm::function_ref<void (mlir::Pattern const&)>, llvm::function_ref<mlir::LogicalResult (mlir::Pattern const&)>)::$_2>(long) PatternApplicator.cpp:0:0
#12 0x0000562f20510e33 mlir::PatternApplicator::matchAndRewrite(mlir::Operation*, mlir::PatternRewriter&, llvm::function_ref<bool (mlir::Pattern const&)>, llvm::function_ref<void (mlir::Pattern const&)>, llvm::function_ref<mlir::LogicalResult (mlir::Pattern const&)>)
#13 0x0000562f204e6918 (anonymous namespace)::OperationLegalizer::legalize(mlir::Operation*, mlir::ConversionPatternRewriter&) DialectConversion.cpp:0:0
#14 0x0000562f204e60c2 mlir::OperationConverter::convert(mlir::ConversionPatternRewriter&, mlir::Operation*)
#15 0x0000562f204e6d3e mlir::OperationConverter::convertOperations(llvm::ArrayRef<mlir::Operation*>)
#16 0x0000562f204eb132 mlir::applyPartialConversion(llvm::ArrayRef<mlir::Operation*>, mlir::ConversionTarget const&, mlir::FrozenRewritePatternSet const&, mlir::ConversionConfig)
#17 0x0000562f204eb8a1 mlir::applyPartialConversion(mlir::Operation*, mlir::ConversionTarget const&, mlir::FrozenRewritePatternSet const&, mlir::ConversionConfig)
#18 0x0000562f1fd7ec38 (anonymous namespace)::ConvertHLFIRtoFIR::runOnOperation() ConvertToFIR.cpp:0:0
#19 0x0000562f21ab1584 void llvm::function_ref<void ()>::callback_fn<mlir::detail::OpToOpPassAdaptor::run(mlir::Pass*, mlir::Operation*, mlir::AnalysisManager, bool, unsigned int)::$_7>(long) Pass.cpp:0:0
#20 0x0000562f21aada67 mlir::detail::OpToOpPassAdaptor::run(mlir::Pass*, mlir::Operation*, mlir::AnalysisManager, bool, unsigned int)
#21 0x0000562f21aade6f mlir::detail::OpToOpPassAdaptor::runPipeline(mlir::OpPassManager&, mlir::Operation*, mlir::AnalysisManager, bool, unsigned int, mlir::PassInstrumentor*, mlir::PassInstrumentation::PipelineParentInfo const*)
#22 0x0000562f21aaf777 mlir::PassManager::run(mlir::Operation*)
#23 0x0000562f1f1ac058 Fortran::frontend::CodeGenAction::generateLLVMIR()
#24 0x0000562f1f1ad727 Fortran::frontend::CodeGenAction::executeAction()
#25 0x0000562f1eda18bc Fortran::frontend::FrontendAction::execute()
#26 0x0000562f1ed96264 Fortran::frontend::CompilerInstance::executeAction(Fortran::frontend::FrontendAction&)
#27 0x0000562f1eda46c6 Fortran::frontend::executeCompilerInvocation(Fortran::frontend::CompilerInstance*)
#28 0x0000562f1ea484d5 fc1_main(llvm::ArrayRef<char const*>, char const*)
#29 0x0000562f1ea474a6 main
#30 0x00007fa7c2468d90 __libc_start_call_main ./csu/../sysdeps/nptl/libc_start_call_main.h:58:16
#31 0x00007fa7c2468e40 call_init ./csu/../csu/libc-start.c:128:20
#32 0x00007fa7c2468e40 __libc_start_main ./csu/../csu/libc-start.c:379:5
#33 0x0000562f1ea46a05 _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 19.0.0git (https://github.com/llvm/llvm-project.git 330af6ed6194ca5365bc576517c247f545aee1f4)
Target: x86_64-unknown-linux-gnu
Thread model: posix
```
</pre>
<img width="1px" height="1px" alt="" src="http://email.email.llvm.org/o/eJzsWVtv2zj2_zTMCxFDInV9yIPrjP9ToIMWafB_NWjqyOaWIgWSSpP59AtSsnWJ6yQ7s9h92KJFxcv5nfshecysFQcFcIfSTyi9v2GdO2pz9-OWGaN_2pu9rl7uHqA1uuo4GIxIgbKolkwdbhX8xLcc3_YjeG7BiAaUY_K21fKl0aY9CttgB9at6jJCWYRIiaJ7FK39d_jLtbJawjBLEsyZGynCbGv0wbAep5_BGGPRtFJw4bDS6kR-XuSSWetlJWvPkmxaLZTz8tM1omvc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