https://bugs.llvm.org/show_bug.cgi?id=33540
Bug ID: 33540
Summary: Analyzer reports seemingly trivially-false leak of
memory
Product: clang
Version: trunk
Hardware: PC
OS: All
Status: NEW
Severity: enhancement
Priority: P
Component: Static Analyzer
Assignee: kreme...@apple.com
Reporter: george.burgess...@gmail.com
CC: llvm-bugs@lists.llvm.org
Repro on trunk:
int *foo(unsigned long bar, bool baz) {
int *i = reinterpret_cast<int *>(bar);
if (!i)
i = new int;
if (baz)
return i;
if (!bar)
delete i;
return 0;
}
Command: $clang --analyze foo.cpp
foo.cpp:9:10: warning: Potential leak of memory pointed to by 'i'
return 0;
^
If I change the `if (!i)` to `if (!bar)`, the warning disappears.
Warning does not disappear if I use `uintptr_t` instead of `unsigned long`.
Thank you!
--
You are receiving this mail because:
You are on the CC list for the bug.
_______________________________________________
llvm-bugs mailing list
llvm-bugs@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-bugs