https://bugs.llvm.org/show_bug.cgi?id=50214
Bug ID: 50214
Summary: unix.MallocSizeof false positive
Product: clang
Version: 11.0
Hardware: PC
OS: Windows NT
Status: NEW
Severity: normal
Priority: P
Component: Static Analyzer
Assignee: dcough...@apple.com
Reporter: org...@gmail.com
CC: dcough...@apple.com, llvm-bugs@lists.llvm.org
test.c:
#include <stdlib.h>
struct Foo { int member; };
int main() {
void **foo = (void **)malloc(sizeof(struct Foo *));
free(foo);
}
$ scan-build gcc test.c
scan-build: Using '/usr/lib/llvm-11/bin/clang' for static analysis
test.c:6:25: warning: Result of 'malloc' is converted to a pointer of type
'void *', which is incompatible with sizeof operand type 'struct Foo *'
[unix.MallocSizeof]
void **foo = (void **)malloc(sizeof(struct Foo *));
~~~~~~~ ^~~~~~ ~~~~~~~~~~~~~~~~~~~~
sizeof is the same for all pointer types.
--
You are receiving this mail because:
You are on the CC list for the bug.
_______________________________________________
llvm-bugs mailing list
llvm-bugs@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-bugs