<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 - Detect buffer underflow"
   href="https://bugs.llvm.org/show_bug.cgi?id=47130">47130</a>
          </td>
        </tr>

        <tr>
          <th>Summary</th>
          <td>Detect buffer underflow
          </td>
        </tr>

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

        <tr>
          <th>Version</th>
          <td>11.0
          </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>enhancement
          </td>
        </tr>

        <tr>
          <th>Priority</th>
          <td>P
          </td>
        </tr>

        <tr>
          <th>Component</th>
          <td>Static Analyzer
          </td>
        </tr>

        <tr>
          <th>Assignee</th>
          <td>dcoughlin@apple.com
          </td>
        </tr>

        <tr>
          <th>Reporter</th>
          <td>orgads@gmail.com
          </td>
        </tr>

        <tr>
          <th>CC</th>
          <td>dcoughlin@apple.com, llvm-bugs@lists.llvm.org
          </td>
        </tr></table>
      <p>
        <div>
        <pre>It would be nice if Clang Analyzer detected buffer underflow.

For example:
#include <string.h>

typedef int BOOL;
#define ELEMENTS 20
BOOL array[ELEMENTS];

void foo()
{
    memset(array,0, ELEMENTS); /* BOOL isn't 1 byte but 4 bytes long */
}


PVS-Studio detects this. See <a href="https://godbolt.org/z/hen3Kn">https://godbolt.org/z/hen3Kn</a>

Source:
<a href="https://stackoverflow.com/q/26102671/764870">https://stackoverflow.com/q/26102671/764870</a></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>