<html>
    <head>
      <base href="https://bugs.llvm.org/">
    </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 - [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."
   href="https://bugs.llvm.org/show_bug.cgi?id=51066">51066</a>
          </td>
        </tr>

        <tr>
          <th>Summary</th>
          <td>[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.
          </td>
        </tr>

        <tr>
          <th>Product</th>
          <td>new-bugs
          </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>new bugs
          </td>
        </tr>

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

        <tr>
          <th>Reporter</th>
          <td>dimitry@andric.com
          </td>
        </tr>

        <tr>
          <th>CC</th>
          <td>htmldeveloper@gmail.com, llvm-bugs@lists.llvm.org
          </td>
        </tr></table>
      <p>
        <div>
        <pre>As reported in <a href="https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=257132">https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=257132</a>, 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...</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>