[llvm-bugs] [Bug 37571] New: Incorrect warning for mempcpy

via llvm-bugs llvm-bugs at lists.llvm.org
Wed May 23 15:02:52 PDT 2018


https://bugs.llvm.org/show_bug.cgi?id=37571

            Bug ID: 37571
           Summary: Incorrect warning for mempcpy
           Product: clang
           Version: unspecified
          Hardware: PC
                OS: Linux
            Status: NEW
          Severity: enhancement
          Priority: P
         Component: LLVM Codegen
          Assignee: unassignedclangbugs at nondot.org
          Reporter: david.bolvansky at gmail.com
                CC: llvm-bugs at lists.llvm.org

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);

-- 
You are receiving this mail because:
You are on the CC list for the bug.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-bugs/attachments/20180523/3b0f1cd5/attachment.html>


More information about the llvm-bugs mailing list