[llvm-bugs] [Bug 28314] New: Crash in tryEvaluateBuiltinObjectSize on invalid FieldDecl's

via llvm-bugs llvm-bugs at lists.llvm.org
Sun Jun 26 13:42:33 PDT 2016


https://llvm.org/bugs/show_bug.cgi?id=28314

            Bug ID: 28314
           Summary: Crash in tryEvaluateBuiltinObjectSize on invalid
                    FieldDecl's
           Product: clang
           Version: trunk
          Hardware: PC
                OS: All
            Status: NEW
          Severity: normal
          Priority: P
         Component: Frontend
          Assignee: unassignedclangbugs at nondot.org
          Reporter: vsk at apple.com
                CC: llvm-bugs at lists.llvm.org
    Classification: Unclassified

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 https://twitter.com/endrift/status/724273399191605248.

-- 
You are receiving this mail because:
You are on the CC list for the bug.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-bugs/attachments/20160626/943f09e0/attachment.html>


More information about the llvm-bugs mailing list