[LLVMbugs] [Bug 16942] New: clang should warn about memcmp of pointers to structs with padding

bugzilla-daemon at llvm.org bugzilla-daemon at llvm.org
Tue Aug 20 09:05:08 PDT 2013


http://llvm.org/bugs/show_bug.cgi?id=16942

            Bug ID: 16942
           Summary: clang should warn about memcmp of pointers to structs
                    with padding
           Product: clang
           Version: unspecified
          Hardware: PC
                OS: All
            Status: NEW
          Severity: normal
          Priority: P
         Component: Frontend
          Assignee: unassignedclangbugs at nondot.org
          Reporter: clattner at apple.com
                CC: llvmbugs at cs.uiuc.edu
    Classification: Unclassified

This is almost always a bug:


#include <string.h>

struct foo {
  char x; int y;
};

int test(struct foo *P, struct foo *Q) {
  return memcmp(P, Q, sizeof(struct foo));
}

because the padding between the elements of the struct fields is being compared
as well.  It would be nice for clang to warn on this.  LLVM itself tripped over
this recently.

-- 
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/20130820/afa3494c/attachment.html>


More information about the llvm-bugs mailing list