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

    <tr>
        <th>Summary</th>
        <td>
            Crash on usage incomplete type with __is_trivially_destructible
        </td>
    </tr>

    <tr>
      <th>Labels</th>
      <td>
            new issue
      </td>
    </tr>

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

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

<pre>
    This problem was found while using clangd and was reduced from `std::optional` in the MSVC STL.
Problem was discovered on LLVM 16, though is reproducible on LLVM trunk.

````
class IncompleteType;

template<bool b>
struct ForceCalculate
{
 using type = IncompleteType;
};

template<typename t>
struct RequiresCompleteType
{
   static constexpr bool value = __is_trivially_destructible(t);
};

template<typename t>
using Base = typename ForceCalculate<RequiresCompleteType<t>::value>::type;

template<typename t>
struct Redirect : Base<t>
{
   using Base<t>::operator*;
};

void f(Redirect<IncompleteType> &a)
{
 *a;
}
````
[Compiler-explorer link](https://compiler-explorer.com/z/b3zWa3f49)

Compiler output:
````
<source>:14:34: error: incomplete type 'IncompleteType' used in type trait expression
   14 |    static constexpr bool value = __is_trivially_destructible(t);
      | ^
<source>:18:63: note: in instantiation of static data member 'RequiresCompleteType<IncompleteType>::value' requested here
   18 | using Base = typename ForceCalculate<RequiresCompleteType<t>::value>::type;
 | ^
<source>:21:19: note: in instantiation of template type alias 'Base' requested here
   21 | struct Redirect : Base<t>
      | ^
<source>:28:4: note: in instantiation of template class 'Redirect<IncompleteType>' requested here
   28 |    *a;
      | ^
<source>:3:7: note: forward declaration of 'IncompleteType'
    3 | class IncompleteType;
      |       ^
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-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 -std=c++20 <source>
1.      <source>:28:6: current parser token ';'
2.      <source>:27:1: parsing function body 'f'
3.      <source>:27:1: in compound statement ('{}')
 #0 0x0000000003988e88 llvm::sys::PrintStackTrace(llvm::raw_ostream&, int) (/opt/compiler-explorer/clang-trunk/bin/clang+++0x3988e88)
 #1 0x0000000003986fd4 llvm::sys::CleanupOnSignal(unsigned long) (/opt/compiler-explorer/clang-trunk/bin/clang+++0x3986fd4)
 #2 0x00000000038d7ac8 CrashRecoverySignalHandler(int) CrashRecoveryContext.cpp:0:0
 #3 0x00007f70c2642520 (/lib/x86_64-linux-gnu/libc.so.6+0x42520)
 #4 0x0000000000bb19a2 clang::Sema::AddMethodCandidate(clang::CXXMethodDecl*, clang::DeclAccessPair, clang::CXXRecordDecl*, clang::QualType, clang::Expr::Classification, llvm::ArrayRef<clang::Expr*>, clang::OverloadCandidateSet&, bool, bool, llvm::MutableArrayRef<clang::ImplicitConversionSequence>, clang::OverloadCandidateParamOrder) (.cold) SemaOverload.cpp:0:0
 #5 0x0000000006d8a571 clang::Sema::AddMethodCandidate(clang::DeclAccessPair, clang::QualType, clang::Expr::Classification, llvm::ArrayRef<clang::Expr*>, clang::OverloadCandidateSet&, bool, clang::OverloadCandidateParamOrder) (/opt/compiler-explorer/clang-trunk/bin/clang+++0x6d8a571)
 #6 0x0000000006d8a76a clang::Sema::AddMemberOperatorCandidates(clang::OverloadedOperatorKind, clang::SourceLocation, llvm::ArrayRef<clang::Expr*>, clang::OverloadCandidateSet&, clang::OverloadCandidateParamOrder) (/opt/compiler-explorer/clang-trunk/bin/clang+++0x6d8a76a)
 #7 0x0000000006d9523f clang::Sema::CreateOverloadedUnaryOp(clang::SourceLocation, clang::UnaryOperatorKind, clang::UnresolvedSetImpl const&, clang::Expr*, bool) (/opt/compiler-explorer/clang-trunk/bin/clang+++0x6d9523f)
 #8 0x000000000691db72 clang::Sema::BuildUnaryOp(clang::Scope*, clang::SourceLocation, clang::UnaryOperatorKind, clang::Expr*, bool) (/opt/compiler-explorer/clang-trunk/bin/clang+++0x691db72)
 #9 0x000000000637f8ae clang::Parser::ParseCastExpression(clang::Parser::CastParseKind, bool, bool&, clang::Parser::TypeCastState, bool, bool*) (/opt/compiler-explorer/clang-trunk/bin/clang+++0x637f8ae)
#10 0x00000000063813ba clang::Parser::ParseCastExpression(clang::Parser::CastParseKind, bool, clang::Parser::TypeCastState, bool, bool*) (/opt/compiler-explorer/clang-trunk/bin/clang+++0x63813ba)
#11 0x0000000006381589 clang::Parser::ParseAssignmentExpression(clang::Parser::TypeCastState) (/opt/compiler-explorer/clang-trunk/bin/clang+++0x6381589)
#12 0x00000000063867d9 clang::Parser::ParseExpression(clang::Parser::TypeCastState) (/opt/compiler-explorer/clang-trunk/bin/clang+++0x63867d9)
#13 0x0000000006411b67 clang::Parser::ParseExprStatement(clang::Parser::ParsedStmtContext) (/opt/compiler-explorer/clang-trunk/bin/clang+++0x6411b67)
#14 0x0000000006406111 clang::Parser::ParseStatementOrDeclarationAfterAttributes(llvm::SmallVector<clang::Stmt*, 32u>&, clang::Parser::ParsedStmtContext, clang::SourceLocation*, clang::ParsedAttributes&, clang::ParsedAttributes&) (/opt/compiler-explorer/clang-trunk/bin/clang+++0x6406111)
#15 0x0000000006406b8d clang::Parser::ParseStatementOrDeclaration(llvm::SmallVector<clang::Stmt*, 32u>&, clang::Parser::ParsedStmtContext, clang::SourceLocation*) (/opt/compiler-explorer/clang-trunk/bin/clang+++0x6406b8d)
#16 0x0000000006407ea4 clang::Parser::ParseCompoundStatementBody(bool) (/opt/compiler-explorer/clang-trunk/bin/clang+++0x6407ea4)
#17 0x000000000640a11a clang::Parser::ParseFunctionStatementBody(clang::Decl*, clang::Parser::ParseScope&) (/opt/compiler-explorer/clang-trunk/bin/clang+++0x640a11a)
#18 0x0000000006306426 clang::Parser::ParseFunctionDefinition(clang::ParsingDeclarator&, clang::Parser::ParsedTemplateInfo const&, clang::Parser::LateParsedAttrList*) (/opt/compiler-explorer/clang-trunk/bin/clang+++0x6306426)
#19 0x000000000634ffcf clang::Parser::ParseDeclGroup(clang::ParsingDeclSpec&, clang::DeclaratorContext, clang::ParsedAttributes&, clang::Parser::ParsedTemplateInfo&, clang::SourceLocation*, clang::Parser::ForRangeInit*) (/opt/compiler-explorer/clang-trunk/bin/clang+++0x634ffcf)
#20 0x00000000062fe9d7 clang::Parser::ParseDeclOrFunctionDefInternal(clang::ParsedAttributes&, clang::ParsedAttributes&, clang::ParsingDeclSpec&, clang::AccessSpecifier) (/opt/compiler-explorer/clang-trunk/bin/clang+++0x62fe9d7)
#21 0x00000000062ff7f3 clang::Parser::ParseDeclarationOrFunctionDefinition(clang::ParsedAttributes&, clang::ParsedAttributes&, clang::ParsingDeclSpec*, clang::AccessSpecifier) (/opt/compiler-explorer/clang-trunk/bin/clang+++0x62ff7f3)
#22 0x00000000063090e2 clang::Parser::ParseExternalDeclaration(clang::ParsedAttributes&, clang::ParsedAttributes&, clang::ParsingDeclSpec*) (/opt/compiler-explorer/clang-trunk/bin/clang+++0x63090e2)
#23 0x000000000630a978 clang::Parser::ParseTopLevelDecl(clang::OpaquePtr<clang::DeclGroupRef>&, clang::Sema::ModuleImportState&) (/opt/compiler-explorer/clang-trunk/bin/clang+++0x630a978)
#24 0x00000000062f904a clang::ParseAST(clang::Sema&, bool, bool) (/opt/compiler-explorer/clang-trunk/bin/clang+++0x62f904a)
#25 0x00000000042d03a5 clang::CodeGenAction::ExecuteAction() (/opt/compiler-explorer/clang-trunk/bin/clang+++0x42d03a5)
#26 0x00000000045996e1 clang::FrontendAction::Execute() (/opt/compiler-explorer/clang-trunk/bin/clang+++0x45996e1)
#27 0x000000000451968b clang::CompilerInstance::ExecuteAction(clang::FrontendAction&) (/opt/compiler-explorer/clang-trunk/bin/clang+++0x451968b)
#28 0x000000000467db73 clang::ExecuteCompilerInvocation(clang::CompilerInstance*) (/opt/compiler-explorer/clang-trunk/bin/clang+++0x467db73)
#29 0x0000000000cee39c cc1_main(llvm::ArrayRef<char const*>, char const*, void*) (/opt/compiler-explorer/clang-trunk/bin/clang+++0xcee39c)
#30 0x0000000000ce6dfd ExecuteCC1Tool(llvm::SmallVectorImpl<char const*>&, llvm::ToolContext const&) driver.cpp:0:0
#31 0x0000000004318289 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
#32 0x00000000038d7ef3 llvm::CrashRecoveryContext::RunSafely(llvm::function_ref<void ()>) (/opt/compiler-explorer/clang-trunk/bin/clang+++0x38d7ef3)
#33 0x00000000043184a9 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
#34 0x00000000042dfd8d clang::driver::Compilation::ExecuteCommand(clang::driver::Command const&, clang::driver::Command const*&, bool) const (/opt/compiler-explorer/clang-trunk/bin/clang+++0x42dfd8d)
#35 0x00000000042e0d8d clang::driver::Compilation::ExecuteJobs(clang::driver::JobList const&, llvm::SmallVectorImpl<std::pair<int, clang::driver::Command const*>>&, bool) const (/opt/compiler-explorer/clang-trunk/bin/clang+++0x42e0d8d)
#36 0x00000000042ea33c clang::driver::Driver::ExecuteCompilation(clang::driver::Compilation&, llvm::SmallVectorImpl<std::pair<int, clang::driver::Command const*>>&) (/opt/compiler-explorer/clang-trunk/bin/clang+++0x42ea33c)
#37 0x0000000000ceb0f1 clang_main(int, char**, llvm::ToolContext const&) (/opt/compiler-explorer/clang-trunk/bin/clang+++0xceb0f1)
#38 0x0000000000bbc204 main (/opt/compiler-explorer/clang-trunk/bin/clang+++0xbbc204)
#39 0x00007f70c2629d90 (/lib/x86_64-linux-gnu/libc.so.6+0x29d90)
#40 0x00007f70c2629e40 __libc_start_main (/lib/x86_64-linux-gnu/libc.so.6+0x29e40)
#41 0x0000000000ce689e _start (/opt/compiler-explorer/clang-trunk/bin/clang+++0xce689e)
clang++: error: clang frontend command failed with exit code 139 (use -v to see invocation)
Compiler returned: 139
````
</pre>
<img width="1px" height="1px" alt="" src="http://email.email.llvm.org/o/eJzkW99z27aT_2voF4w8JEiJ1IMfZNnuOedMfJGby5sGBJYSLhTAAqBi96-_AUhKBC3JbqqknflmWocmfuxnP7vYXYAI0ZqvBMBVML4OxjcXpDZrqa4-fJlVIC5yyV6untZco0rJvIQN-k40KmQtGPq-5iWgWnOxQrQkYsUQsa-JRgpYTYGhQskNCiahNiyIZ0E8k5XhUpAymISIC2TWgD4uvszR4unhMghvgnD22JPDuKZyCwoYkgI9PHz5iKJJgOfIrGW9WiNuJVVKspryvIRdJ6Nq8a2dr_05Cff_uTe0JFqje0HlpirBwNNLBUF83R9kYFOVxEAQz3MpS5QH8W3Too2qqUF3UlGYk5LWrlszNG3naJkxLxWgIL45Kiq9OS7WDhZkA8gMRX-GP2quQM_7cw4AIKQNMZwiKoU28Fwp5PTYkrJuMC2XXC-N4ltOyvJlyaCZ3ZIZ4MwEePrDOBvtr4luJO16DDiL5wc1ieduJuczDu7uN3PSTqcIY1wBNSiIZw5WJ-MVaXvkHgxZgSJGqgDPTpCylZyhIsBZJy-I50PL36IAT4gldyA7wDPizX3Ed4PxtWWLl6BG8FyVUoFCJRffgvFNgLO1MZW2oPFdgO_osOcllZsA3_0Z4Ls8_vN_SVwk0z0Y97ObHcnaVLWxcx2DEs-1rBVtDRQlQTyL7Q8ESkllH_hO_XYx4HTACE5RrYG5iGB7GEW4QdZhQWsuxc40UYKCdI7O69nI_bHzBuPbw1plQTybxFYZIa2fWaUQF9oQYTixIQ3JosPEiCFoA5sclNX1iH-_coq-s-MUKfijBm2AoTUo2DOQOaS_ZHWd5ARHlpjpW5x0a7MxLCk50ZYUt7qOa4kjJ_tdS_dt82FrvuTdSJvM4Cx3fAmfAp91Tu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