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

            Bug ID: 51066
           Summary: [x86] Assertion failed: ((EltVT.getSizeInBits() >= 64
                    || (uint64_t)((int64_t)Val >> EltVT.getSizeInBits()) +
                    1 < 2) && "getConstant with a uint64_t value that
                    doesn't fit in the type!"), function getConstant, file
                    SelectionDAG.cpp, line 1188.
           Product: new-bugs
           Version: trunk
          Hardware: PC
                OS: All
            Status: NEW
          Severity: normal
          Priority: P
         Component: new bugs
          Assignee: unassignedb...@nondot.org
          Reporter: dimi...@andric.com
                CC: htmldevelo...@gmail.com, llvm-bugs@lists.llvm.org

As reported in https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=257132, clang
asserts when cross-building for an i386 target on amd64:

Assertion failed: ((EltVT.getSizeInBits() >= 64 || (uint64_t)((int64_t)Val >>
EltVT.getSizeInBits()) + 1 < 2) && "getConstant with a uint64_t value that
doesn't fit in the type!"), function getConstant, file
/usr/local/release-builds/i386/usr/src/contrib/llvm-project/llvm/lib/CodeGen/SelectionDAG/SelectionDAG.cpp,
line 1337.

Minimize test case:

// clang -cc1 -triple i386-- -S -O1 kern_mbuf-min.c
int a;
struct b {
  int c;
  char d[-sizeof(0)];
  int e;
} f();
void g() {
  struct b *h = (struct b *)a;
  if (h->e)
    f();
}

Note that setting the target to x86_64 makes the assertion go away, and shows
an (expected) error message instead:

kern_mbuf-min.c:5:10: error: array is too large (18446744073709551612 elements)
  char d[-sizeof(0)];
         ^~~~~~~~~~
kern_mbuf-min.c:9:17: warning: cast to 'struct b *' from smaller integer type
'int' [-Wint-to-pointer-cast]
  struct b *h = (struct b *)a;
                ^~~~~~~~~~~~~
1 warning and 1 error generated.

I have tested this with various versions of clang, and even the oldest I had
lying around (clang 3.1, trunk r150000!) gave the same assertion...

-- 
You are receiving this mail because:
You are on the CC list for the bug.
_______________________________________________
llvm-bugs mailing list
llvm-bugs@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-bugs

Reply via email to