[llvm-bugs] [Bug 36242] New: memset(foo, sizeof(foo), 0) should warn
    via llvm-bugs 
    llvm-bugs at lists.llvm.org
       
    Mon Feb  5 13:17:28 PST 2018
    
    
  
https://bugs.llvm.org/show_bug.cgi?id=36242
            Bug ID: 36242
           Summary: memset(foo,sizeof(foo),0) should warn
           Product: clang
           Version: trunk
          Hardware: PC
                OS: Linux
            Status: NEW
          Severity: enhancement
          Priority: P
         Component: Frontend
          Assignee: unassignedclangbugs at nondot.org
          Reporter: felix-llvm at fefe.de
                CC: llvm-bugs at lists.llvm.org
Consider this code:
#include <string.h>
int main() {
  char buf[100];
  memset(buf,sizeof(buf),0);
}
gcc -Wall will warn about this:
t.c: In function ‘main’:
t.c:6:3: warning: ‘memset’ used with constant zero length parameter; this could
be due to transposed parameters [-Wmemset-transposed-args]
   memset(buf,sizeof(buf),0);
   ^~~~~~
I think clang should warn about this, too.
I tried clang 5.0.1 and 7.0.0 (trunk 323933) with -Weverything and got no
warning.
It could be argued that this belongs in the static analyzer, but even with
scan-build I get no warnings about this.
-- 
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/20180205/ea36af9f/attachment.html>
    
    
More information about the llvm-bugs
mailing list