<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 - Incorrect warning for mempcpy"
   href="https://bugs.llvm.org/show_bug.cgi?id=37571">37571</a>
          </td>
        </tr>

        <tr>
          <th>Summary</th>
          <td>Incorrect warning for mempcpy
          </td>
        </tr>

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

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

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

        <tr>
          <th>Component</th>
          <td>LLVM Codegen
          </td>
        </tr>

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

        <tr>
          <th>Reporter</th>
          <td>david.bolvansky@gmail.com
          </td>
        </tr>

        <tr>
          <th>CC</th>
          <td>llvm-bugs@lists.llvm.org
          </td>
        </tr></table>
      <p>
        <div>
        <pre>Hello,

void* foo(const void *src, void *dst, size_t n) {
    return mempcpy(dst, src, n);
}

Clang -O0 warns:

mm.c:6:12: warning: incompatible integer to pointer conversion returning 'int'
      from a function with result type 'void *' [-Wint-conversion]
    return mempcpy(dst, src, n);


Clang -O3 (to show smaller IR code):
define dso_local i8* @foo(i8* %src, i8* %dst, i64 %n) local_unnamed_addr #0 {
entry:
  %call = tail call i32 (i8*, i8*, i64, ...) bitcast (i32 (...)* @mempcpy to
i32 (i8*, i8*, i64, ...)*)(i8* %dst, i8* %src, i64 %n) #3
  %conv = sext i32 %call to i64
  %0 = inttoptr i64 %conv to i8*
  ret i8* %0
}

declare dso_local i32 @mempcpy(...)


Signature:
void *mempcpy(void *dest, const void *src, size_t n);</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>