<html>
    <head>
      <base href="https://llvm.org/bugs/" />
    </head>
    <body><table border="1" cellspacing="0" cellpadding="8">
        <tr>
          <th>Bug ID</th>
          <td><a class="bz_bug_link 
          bz_status_NEW "
   title="NEW --- - Crash in tryEvaluateBuiltinObjectSize on invalid FieldDecl's"
   href="https://llvm.org/bugs/show_bug.cgi?id=28314">28314</a>
          </td>
        </tr>

        <tr>
          <th>Summary</th>
          <td>Crash in tryEvaluateBuiltinObjectSize on invalid FieldDecl's
          </td>
        </tr>

        <tr>
          <th>Product</th>
          <td>clang
          </td>
        </tr>

        <tr>
          <th>Version</th>
          <td>trunk
          </td>
        </tr>

        <tr>
          <th>Hardware</th>
          <td>PC
          </td>
        </tr>

        <tr>
          <th>OS</th>
          <td>All
          </td>
        </tr>

        <tr>
          <th>Status</th>
          <td>NEW
          </td>
        </tr>

        <tr>
          <th>Severity</th>
          <td>normal
          </td>
        </tr>

        <tr>
          <th>Priority</th>
          <td>P
          </td>
        </tr>

        <tr>
          <th>Component</th>
          <td>Frontend
          </td>
        </tr>

        <tr>
          <th>Assignee</th>
          <td>unassignedclangbugs@nondot.org
          </td>
        </tr>

        <tr>
          <th>Reporter</th>
          <td>vsk@apple.com
          </td>
        </tr>

        <tr>
          <th>CC</th>
          <td>llvm-bugs@lists.llvm.org
          </td>
        </tr>

        <tr>
          <th>Classification</th>
          <td>Unclassified
          </td>
        </tr></table>
      <p>
        <div>
        <pre>The latest ToT clang crashes on the following input [1]:

```
$ clang -cc1 -emit-obj -o /dev/null -x c - <<EOF
struct A {
  struct B b;
  char c[1];
};
void d(struct A *a) {
  __builtin_object_size(a->c, 1), "";
}
EOF
```

Assertion failed: (!D->isInvalidDecl() && "Cannot get layout of invalid
decl!"), function getASTRecordLayout

One hacky fix is to change ``IsLastFieldDecl`` to ``IsLastOrInvalidFieldDecl``,
and conservatively return true if ``FD->getParent()->isInvalidDecl()``.

However, that fix doesn't explain why the comma and the string literal
following the call to __builtin_object_size() in this test case are
significant.

[1] CReduced from <a href="https://twitter.com/endrift/status/724273399191605248">https://twitter.com/endrift/status/724273399191605248</a>.</pre>
        </div>
      </p>
      <hr>
      <span>You are receiving this mail because:</span>
      
      <ul>
          <li>You are on the CC list for the bug.</li>
      </ul>
    </body>
</html>