<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 - -Warray-bounds false negative when casting an out-of-bounds array item"
   href="https://bugs.llvm.org/show_bug.cgi?id=44343">44343</a>
          </td>
        </tr>

        <tr>
          <th>Summary</th>
          <td>-Warray-bounds false negative when casting an out-of-bounds array item
          </td>
        </tr>

        <tr>
          <th>Product</th>
          <td>clang
          </td>
        </tr>

        <tr>
          <th>Version</th>
          <td>trunk
          </td>
        </tr>

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

        <tr>
          <th>OS</th>
          <td>Linux
          </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>Frontend
          </td>
        </tr>

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

        <tr>
          <th>Reporter</th>
          <td>ilya.mirsky@ericsson.com
          </td>
        </tr>

        <tr>
          <th>CC</th>
          <td>llvm-bugs@lists.llvm.org, neeilans@live.com, richard-llvm@metafoo.co.uk
          </td>
        </tr></table>
      <p>
        <div>
        <pre>For the following code in array-bounds.cpp

  unsigned int arr[2] = {0, 1};
  int i1 = arr[4];
  int i2 = (int)(arr[4]);
  int i3 = static_cast<int>(arr[4]);

Clang warns only for `i1`'s assignment. When the array item is casted, no out
of bounds warning is presented.

  $ clang -cc1 -Warray-bounds array-bounds.cpp
  array-bounds.cpp:2:10: warning: array index 4 is past the end of the array 
  (which contains 2 elements)
  int i1 = arr[4];
           ^   ~
  array-bounds.cpp:1:1: note: array 'arr' declared here
  unsigned int arr[2] = {0, 1};
  ^
  1 warning generated.


This is not a duplicate of PR10771, as in the latter the subscript operator is
applied on the casted array, whereas in this case, the subscript operator is
applied first and then casting applied on the result.</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>