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

    <tr>
        <th>Summary</th>
        <td>
            Crash when __datasizeof is used on a type with incomplete fields
        </td>
    </tr>

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

    <tr>
      <th>Assignees</th>
      <td>
            ilya-biryukov
      </td>
    </tr>

    <tr>
      <th>Reporter</th>
      <td>
          ilya-biryukov
      </td>
    </tr>
</table>

<pre>
    ```cpp
struct Bar;
struct Foo {
  Bar x;
};

int test() {
  constexpr int a = __datasizeof(Foo);
}
```
See https://gcc.godbolt.org/z/q1eKveT68.


The stack trace is the following:
```
 #2 0x0000000003527fc8 CrashRecoverySignalHandler(int) CrashRecoveryContext.cpp:0:0
 #3 0x00007fe55b442520 (/lib/x86_64-linux-gnu/libc.so.6+0x42520)
 #4 0x00000000070002bc clang::ASTContext::getASTRecordLayout(clang::RecordDecl const*) const (/opt/compiler-explorer/clang-trunk/bin/clang+++0x70002bc)
 #5 0x00000000070033b1 (anonymous namespace)::EmptySubobjectMap::ComputeEmptySubobjectSizes() RecordLayoutBuilder.cpp:0:0
 #6 0x000000000700034b clang::ASTContext::getASTRecordLayout(clang::RecordDecl const*) const (/opt/compiler-explorer/clang-trunk/bin/clang+++0x700034b)
 #7 0x0000000006b9c3ea clang::ASTContext::getTypeInfoDataSizeInChars(clang::QualType) const (/opt/compiler-explorer/clang-trunk/bin/clang+++0x6b9c3ea)
 #8 0x0000000006dadff1 HandleSizeof((anonymous namespace)::EvalInfo&, clang::SourceLocation, clang::QualType, clang::CharUnits&, SizeOfType) ExprConstant.cpp:0:0
 #9 0x0000000006df63ec clang::StmtVisitorBase<llvm::make_const_ptr, (anonymous namespace)::IntExprEvaluator, bool>::Visit(clang::Stmt const*) ExprConstant.cpp:0:0
#10 0x0000000006ddb66e Evaluate(clang::APValue&, (anonymous namespace)::EvalInfo&, clang::Expr const*) ExprConstant.cpp:0:0
#11 0x0000000006de4b11 EvaluateAsRValue((anonymous namespace)::EvalInfo&, clang::Expr const*, clang::APValue&) ExprConstant.cpp:0:0
#12 0x0000000006de6791 clang::Expr::EvaluateAsRValue(clang::Expr::EvalResult&, clang::ASTContext const&, bool) const (/opt/compiler-explorer/clang-trunk/bin/clang+++0x6de6791)
#13 0x0000000005e60457 GetExprRange(clang::ASTContext&, clang::Expr const*, unsigned int, bool, bool) SemaChecking.cpp:0:0
#14 0x0000000005ebe59f CheckImplicitConversion(clang::Sema&, clang::Expr*, clang::QualType, clang::SourceLocation, bool*, bool) SemaChecking.cpp:0:0
#15 0x0000000005ec13b7 AnalyzeImplicitConversions(clang::Sema&, clang::Expr*, clang::SourceLocation, bool) (.constprop.0) SemaChecking.cpp:0:0

```
</pre>
<img width="1px" height="1px" alt="" src="http://email.email.llvm.org/o/eJzMVk1z4zYP_jX0hWMPRerDPvhgO6v3zXQ7beN0rxmKgm02FKmSVGLn13coyR9ykmY3s4dmHJsiQOB5ABACd05uNcAcJUtEqVQHPi6kPTSP5glRipKbEW_8ztj5QDQqTHmYo5R0H1HXiNwgsnDeNsLjJbeILQdbuTEYZf0eDhp4f9JB2c153X5L7bEH5xGdIjq7PCmMdh72tcVBh2PEbvDDQ8k9d_IFzAbRaW4MorOB9W5xxNs9rgHwzvvaIbZANEc03wox2ZqyMMpPjN0imr8gmv8dwS9PcJ9OJ5cIu-_7HWDnuXjE3nIBWDrsd4A3RinzLPU2mH7LN0aUUUz25PjHEpptxBSvLHe7OxDmCexhLbeaq_9zXSqwiE6l9iEaA52V0R72fhJywBak_T-5YL2LbANJUsQxTSjBbUxzJQtE8_00fUjjsZK62Y-3uukEYuLMJEV0SfbtkRDNk834EnZGCKGFwELxjixbLNb3PabueQt-sb4PcG35lR9ME5J6od9JbkCoLreILgLJdt1jNbVHNBemqqUCO4Z9rYwNEclbO2NvG_2IaF5IfdxDdNl9yL7HOCCRXJFgrIiCM66NPlSmcVjzClzNBbS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