[LLVMbugs] [Bug 9977] New: clang should warn on memset(s, 0, sizeof(s)) – needs to be sizeof (*s)

bugzilla-daemon at llvm.org bugzilla-daemon at llvm.org
Fri May 20 16:40:28 PDT 2011


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

           Summary: clang should warn on memset(s, 0, sizeof(s)) – needs
                    to be sizeof(*s)
           Product: clang
           Version: trunk
          Platform: PC
        OS/Version: All
            Status: NEW
          Severity: normal
          Priority: P
         Component: Frontend
        AssignedTo: unassignedclangbugs at nondot.org
        ReportedBy: nicolasweber at gmx.de
                CC: llvmbugs at cs.uiuc.edu


#include <memory.h>

struct S {
  char a;
};

void f(S* s) {
  memset(s, 0, sizeof(s));
}


clang should warn that the memset call is missing a dereference for s. This is
a common error and easy to catch.

-- 
Configure bugmail: http://llvm.org/bugs/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are on the CC list for the bug.



More information about the llvm-bugs mailing list