<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 --- - integer truncation error in areStridedAccessesIndependent"
   href="https://llvm.org/bugs/show_bug.cgi?id=28443">28443</a>
          </td>
        </tr>

        <tr>
          <th>Summary</th>
          <td>integer truncation error in areStridedAccessesIndependent
          </td>
        </tr>

        <tr>
          <th>Product</th>
          <td>new-bugs
          </td>
        </tr>

        <tr>
          <th>Version</th>
          <td>3.8
          </td>
        </tr>

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

        <tr>
          <th>OS</th>
          <td>FreeBSD
          </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>cperciva@freebsd.org
          </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>Created <span class=""><a href="attachment.cgi?id=16701" name="attach_16701" title="Test case; crashes clang38 -O2">attachment 16701</a> <a href="attachment.cgi?id=16701&action=edit" title="Test case; crashes clang38 -O2">[details]</a></span>
Test case; crashes clang38 -O2

The attached reduced test case crashes clang38 -c -O2 on my FreeBSD/amd64
system:

Assertion failed: (Distance > 0 && "The distance must be non-zero"), function
areStridedAccessesIndependent, file
/wrkdirs/usr/ports/devel/llvm38/work/llvm-3.8.0.src/lib/Analysis/LoopAccessAnalysis.cpp,
line 1004.

This is because the function areStridedAccessIndependent takes "unsigned"
values

static bool areStridedAccessesIndependent(unsigned Distance, unsigned Stride,
                                          unsigned TypeByteSize)

where it should be taking target size_t values: I am compiling for a 64-bit
platform, and the distance between memory accesses is 2^32 bytes, but the
"unsigned" type is a 32-bit integer so 2^32 gets truncated to 0.

In addition to causing a crash when the distance between memory accesses is a
multiple of 2^32 bytes, this bug could theoretically cause incorrect code
generation, e.g., if the distance is 2^32+2 bytes and the stride length is
2^31+1; using 32-bit integers it appears that the distance is not a multiple of
the stride length, and invalid optimizations may occur.</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>