<table border="1" cellspacing="0" cellpadding="8">
    <tr>
        <th>Issue</th>
        <td>
            <a href=https://github.com/llvm/llvm-project/issues/111299>111299</a>
        </td>
    </tr>

    <tr>
        <th>Summary</th>
        <td>
            [Clang] [Crash on valid] invalid cast kind for complex value UNREACHABLE executed at /root/llvm-project/clang/lib/AST/ExprConstant.cpp:15565!
        </td>
    </tr>

    <tr>
      <th>Labels</th>
      <td>
            clang
      </td>
    </tr>

    <tr>
      <th>Assignees</th>
      <td>
      </td>
    </tr>

    <tr>
      <th>Reporter</th>
      <td>
          yijan4845
      </td>
    </tr>
</table>

<pre>
    Compiler Explorer: [https://godbolt.org/z/nh7Txcrz8](https://godbolt.org/z/nh7Txcrz8)

Attempting to compile the following program with Clang Assertion Trunk:
```c
_Complex double p[10];
double _Complex
foo (double _Complex x) {
    ++*p;
}
```

Stack dump:
```
invalid cast kind for complex value
UNREACHABLE executed at /root/llvm-project/clang/lib/AST/ExprConstant.cpp:15565!
PLEASE submit a bug report to https://github.com/llvm/llvm-project/issues/ and include the crash backtrace, preprocessed source, and associated run script.
Stack dump:
0.      Program arguments: /opt/compiler-explorer/clang-assertions-trunk/bin/clang -gdwarf-4 -g -o /app/output.s -mllvm --x86-asm-syntax=intel -fno-verbose-asm -S --gcc-toolchain=/opt/compiler-explorer/gcc-snapshot -fcolor-diagnostics -fno-crash-diagnostics -O3 <source>
1.      <source>:5:1: current parser token '}'
2.      <source>:3:25: parsing function body 'foo'
3.      <source>:3:25: in compound statement ('{}')
 #0 0x0000000003b99d28 llvm::sys::PrintStackTrace(llvm::raw_ostream&, int) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+0x3b99d28)
 #1 0x0000000003b979ec llvm::sys::CleanupOnSignal(unsigned long) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+0x3b979ec)
 #2 0x0000000003ae61f8 CrashRecoverySignalHandler(int) CrashRecoveryContext.cpp:0:0
 #3 0x00007561f5a42520 (/lib/x86_64-linux-gnu/libc.so.6+0x42520)
 #4 0x00007561f5a969fc pthread_kill (/lib/x86_64-linux-gnu/libc.so.6+0x969fc)
 #5 0x00007561f5a42476 gsignal (/lib/x86_64-linux-gnu/libc.so.6+0x42476)
 #6 0x00007561f5a287f3 abort (/lib/x86_64-linux-gnu/libc.so.6+0x287f3)
 #7 0x0000000003af1aca (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+0x3af1aca)
 #8 0x0000000007b0cfa4 (anonymous namespace)::ComplexExprEvaluator::VisitCastExpr(clang::CastExpr const*) ExprConstant.cpp:0:0
 #9 0x0000000007b0a9ec clang::StmtVisitorBase<llvm::make_const_ptr, (anonymous namespace)::ComplexExprEvaluator, bool>::Visit(clang::Stmt const*) ExprConstant.cpp:0:0
#10 0x0000000007b0c740 (anonymous namespace)::ComplexExprEvaluator::VisitUnaryOperator(clang::UnaryOperator const*) ExprConstant.cpp:0:0
#11 0x0000000007b0bbdb clang::StmtVisitorBase<llvm::make_const_ptr, (anonymous namespace)::ComplexExprEvaluator, bool>::Visit(clang::Stmt const*) ExprConstant.cpp:0:0
#12 0x0000000007b0c740 (anonymous namespace)::ComplexExprEvaluator::VisitUnaryOperator(clang::UnaryOperator const*) ExprConstant.cpp:0:0
#13 0x0000000007b0bc23 clang::StmtVisitorBase<llvm::make_const_ptr, (anonymous namespace)::ComplexExprEvaluator, bool>::Visit(clang::Stmt const*) ExprConstant.cpp:0:0
#14 0x0000000007b0c393 EvaluateComplex(clang::Expr const*, (anonymous namespace)::ComplexValue&, (anonymous namespace)::EvalInfo&) ExprConstant.cpp:0:0
#15 0x0000000007ac55e4 Evaluate(clang::APValue&, (anonymous namespace)::EvalInfo&, clang::Expr const*) ExprConstant.cpp:0:0
#16 0x0000000007acdd3b EvaluateAsRValue((anonymous namespace)::EvalInfo&, clang::Expr const*, clang::APValue&) ExprConstant.cpp:0:0
#17 0x0000000007acf552 clang::Expr::EvaluateForOverflow(clang::ASTContext const&) const (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+0x7acf552)
#18 0x0000000006848944 clang::Sema::CheckForIntOverflow(clang::Expr const*) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+0x6848944)
#19 0x0000000006875c1d clang::Sema::CheckCompletedExpr(clang::Expr*, clang::SourceLocation, bool) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+0x6875c1d)
#20 0x0000000006d424bc clang::Sema::ActOnFinishFullExpr(clang::Expr*, clang::SourceLocation, bool, bool, bool) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+0x6d424bc)
#21 0x00000000070e4c0e clang::Sema::ActOnExprStmt(clang::ActionResult<clang::Expr*, true>, bool) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+0x70e4c0e)
#22 0x000000000671f544 clang::Parser::ParseExprStatement(clang::Parser::ParsedStmtContext) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+0x671f544)
#23 0x000000000671587c clang::Parser::ParseStatementOrDeclarationAfterAttributes(llvm::SmallVector<clang::Stmt*, 32u>&, clang::Parser::ParsedStmtContext, clang::SourceLocation*, clang::ParsedAttributes&, clang::ParsedAttributes&) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+0x671587c)
#24 0x0000000006716790 clang::Parser::ParseStatementOrDeclaration(llvm::SmallVector<clang::Stmt*, 32u>&, clang::Parser::ParsedStmtContext, clang::SourceLocation*) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+0x6716790)
#25 0x0000000006717665 clang::Parser::ParseCompoundStatementBody(bool) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+0x6717665)
#26 0x0000000006718dba clang::Parser::ParseFunctionStatementBody(clang::Decl*, clang::Parser::ParseScope&) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+0x6718dba)
#27 0x000000000662bec3 clang::Parser::ParseFunctionDefinition(clang::ParsingDeclarator&, clang::Parser::ParsedTemplateInfo const&, clang::Parser::LateParsedAttrList*) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+0x662bec3)
#28 0x00000000066612cd clang::Parser::ParseDeclGroup(clang::ParsingDeclSpec&, clang::DeclaratorContext, clang::ParsedAttributes&, clang::Parser::ParsedTemplateInfo&, clang::SourceLocation*, clang::Parser::ForRangeInit*) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+0x66612cd)
#29 0x000000000661fc0e clang::Parser::ParseDeclOrFunctionDefInternal(clang::ParsedAttributes&, clang::ParsedAttributes&, clang::ParsingDeclSpec&, clang::AccessSpecifier) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+0x661fc0e)
#30 0x00000000066203ce clang::Parser::ParseDeclarationOrFunctionDefinition(clang::ParsedAttributes&, clang::ParsedAttributes&, clang::ParsingDeclSpec*, clang::AccessSpecifier) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+0x66203ce)
#31 0x0000000006627b63 clang::Parser::ParseExternalDeclaration(clang::ParsedAttributes&, clang::ParsedAttributes&, clang::ParsingDeclSpec*) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+0x6627b63)
#32 0x0000000006628a4d clang::Parser::ParseTopLevelDecl(clang::OpaquePtr<clang::DeclGroupRef>&, clang::Sema::ModuleImportState&) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+0x6628a4d)
#33 0x000000000661af6a clang::ParseAST(clang::Sema&, bool, bool) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+0x661af6a)
#34 0x00000000044f0998 clang::CodeGenAction::ExecuteAction() (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+0x44f0998)
#35 0x00000000047aa2e9 clang::FrontendAction::Execute() (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+0x47aa2e9)
#36 0x0000000004728c2e clang::CompilerInstance::ExecuteAction(clang::FrontendAction&) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+0x4728c2e)
#37 0x000000000488fb6e clang::ExecuteCompilerInvocation(clang::CompilerInstance*) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+0x488fb6e)
#38 0x0000000000cd801f cc1_main(llvm::ArrayRef<char const*>, char const*, void*) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+0xcd801f)
#39 0x0000000000ccfd2a ExecuteCC1Tool(llvm::SmallVectorImpl<char const*>&, llvm::ToolContext const&) driver.cpp:0:0
#40 0x0000000004534669 void llvm::function_ref<void ()>::callback_fn<clang::driver::CC1Command::Execute(llvm::ArrayRef<std::optional<llvm::StringRef>>, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>>*, bool*) const::'lambda'()>(long) Job.cpp:0:0
#41 0x0000000003ae66a4 llvm::CrashRecoveryContext::RunSafely(llvm::function_ref<void ()>) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+0x3ae66a4)
#42 0x0000000004534c5f clang::driver::CC1Command::Execute(llvm::ArrayRef<std::optional<llvm::StringRef>>, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>>*, bool*) const (.part.0) Job.cpp:0:0
#43 0x00000000044fa59d clang::driver::Compilation::ExecuteCommand(clang::driver::Command const&, clang::driver::Command const*&, bool) const (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+0x44fa59d)
#44 0x00000000044fb68d clang::driver::Compilation::ExecuteJobs(clang::driver::JobList const&, llvm::SmallVectorImpl<std::pair<int, clang::driver::Command const*>>&, bool) const (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+0x44fb68d)
#45 0x0000000004502fb5 clang::driver::Driver::ExecuteCompilation(clang::driver::Compilation&, llvm::SmallVectorImpl<std::pair<int, clang::driver::Command const*>>&) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+0x4502fb5)
#46 0x0000000000cd4eef clang_main(int, char**, llvm::ToolContext const&) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+0xcd4eef)
#47 0x0000000000ba49a4 main (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+0xba49a4)
#48 0x00007561f5a29d90 (/lib/x86_64-linux-gnu/libc.so.6+0x29d90)
#49 0x00007561f5a29e40 __libc_start_main (/lib/x86_64-linux-gnu/libc.so.6+0x29e40)
#50 0x0000000000ccf7de _start (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+0xccf7de)
clang: error: clang frontend command failed with exit code 134 (use -v to see invocation)
Compiler returned: 134
```
</pre>
<img width="1px" height="1px" alt="" src="http://email.email.llvm.org/o/eJzkWl1z46jS_jXKDWWXhL4vcqE48e5s5X0zlWT31oUQstlIoAMo4-yvPwXIjlFsTzKjbJ2zZ8ozYwvofvrppmkQSEq6ZoRcevGVF19foF5tuLh8oX8iFmVRfFHy6uVywduONkSAm23XcEGEFxbAi682SnXSCwsPLj24XPOq5I2ac7H24PIvDy7ZJn3cYvFX5sXXHsze3x3mnn_t-YX9t1CKtJ2ibA0UB9iCAWpDQM2bhn_TDZ3ga4Fa8I2qDVg0iK1BISURinIGHkXPnrRiKzTx7Qfb3yttXkO2oOJ92RDQefFV4GvI4ZXtMTTsOtqHNefAg9moDWw9mAMvHUYCAIAHr8yn6PYCvfR6hOXQ3geF8BOo-rZ7i9n-pOwZNbQCGEkFniirQM2FYUZDeEZNT2zH3____qZY_Fpc3d4AsiW4V6QCSAEPLgXnyoPLpnluZ53gfxKsf2JNnX5MSw8ui4dHDy5vtp1YcCYVYmqOO40qiOMk9mBgtXy9vSkeboDsy5YqgEDZr4EgHRdKO2zkdqo2fTnHvB2Uv8VApeyJ9OASIFYBynDTV9bfWCC5ASXCT0ogTDy4AJ0gneCYSEkqIHkv7GM9EknJMUXaZNEzILGgnZqf5Nife37-dYgjJNZ9S5iSJtThkneGnWEizMhuIgyMzdAu2ORMmWiDy5KyXTOYratvSNSzCMzWYKYDZ4m6TsvtVderuQSzVrMAZrNtlsyQbGfyhSm09cJryhRpwKxmfPZMRMkl0e1g9gBmszXGM8V5gzeIMi-8PotUd5YMdXLDFZjVmDdczCqK1oxLRbG0OgzH7uO7EHjhYiA3vLF0BZou53FYxDo0NGO4F4IwBTokJBFA8SfCgAdTHfgwtQLgEQGhFxZQSzEj9cSue4bNJNaZSIuoOd-LCM-KoMxMCd6zCk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