<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 - Unittest Sema/./SemaTests.exe/PreferredTypeTest.BinaryExpr failing when host and target have differing sizes for types"
   href="https://bugs.llvm.org/show_bug.cgi?id=40033">40033</a>
          </td>
        </tr>

        <tr>
          <th>Summary</th>
          <td>Unittest Sema/./SemaTests.exe/PreferredTypeTest.BinaryExpr failing when host and target have differing sizes for types
          </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>Windows NT
          </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>douglas_yung@playstation.sony.com
          </td>
        </tr>

        <tr>
          <th>CC</th>
          <td>htmldeveloper@gmail.com, llvm-bugs@lists.llvm.org
          </td>
        </tr></table>
      <p>
        <div>
        <pre>The unittest PreferredTypeTest.BinaryExpr was added upstream in r349053, and
then subsequently updated in r349086 to fix problems on LLP64 platforms.

We see a failure in the following test in our internal builds:

  Code = R"cpp(
    void test(int *ptr) {
      ptr + ^10;
      ptr += ^10;
      ptr -= ^10;
    })cpp";
  // Expect the normalized ptrdiff_t type, which is typically long or long
long.
  const char *PtrDiff = sizeof(void *) == sizeof(long) ? "long" : "long long";
  EXPECT_THAT(collectPreferredTypes(Code), Each(PtrDiff));

The problem is that we use Visual Studio 2015 to build the clang and the
unittest, while test when run on Windows uses the newly built clang (which has
a target of the PS4). The problem is that the calculation of PtrDiff gives a
different answer depending on what your platform is in this case and causes the
test to fail.

On 64bit Windows, we have the following:
sizeof(void *) = 8
sizeof(long)   = 4

While on the PS4 target, we have the following:
sizeof(void *) = 8
sizeof(long)   = 8

This causes a problem because when Visual Studio compiles the unittest, since
it is targeting Windows, the comparison evaluates to false, and PtrDiff is set
to "long long". But when the test is actually run and it takes into
consideration the target platform type sizes, it returns only "long" which
causes the test to fail.</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>