<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 --- - scan-build: false positive w/memset return"
   href="https://llvm.org/bugs/show_bug.cgi?id=25993">25993</a>
          </td>
        </tr>

        <tr>
          <th>Summary</th>
          <td>scan-build: false positive w/memset return
          </td>
        </tr>

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

        <tr>
          <th>Version</th>
          <td>unspecified
          </td>
        </tr>

        <tr>
          <th>Hardware</th>
          <td>All
          </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>Static Analyzer
          </td>
        </tr>

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

        <tr>
          <th>Reporter</th>
          <td>vapier@gmail.com
          </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>scan-build does not seem to understand the relationship between the first arg
and the return value.  from POSIX:
  <a href="http://pubs.opengroup.org/onlinepubs/9699919799/functions/memset.html">http://pubs.opengroup.org/onlinepubs/9699919799/functions/memset.html</a>
  void *memset(void *s, int c, size_t n);
  RETURN VALUE
    The memset() function shall return s;

so when you have code like:
  #include <stdio.h>
  #include <string.h>
  int main(int argc, char *argv[])
  {
      char *s = memset(malloc(10), 0, 10);
      strcpy(s, "abc");
      puts(s);
      return 0;
  }

scan-build wrongly reports:
test.c:5:2: warning: Potential memory leak
        char *s = memset(malloc(10), 0, 10);
        ^~~~~~~
1 warning generated.
scan-build: 1 bug found.</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>