[llvm-bugs] [Bug 39767] New: scan-build false positive: not realizing that "> unsigned" implies "> 0"?
via llvm-bugs
llvm-bugs at lists.llvm.org
Fri Nov 23 22:37:18 PST 2018
https://bugs.llvm.org/show_bug.cgi?id=39767
Bug ID: 39767
Summary: scan-build false positive: not realizing that ">
unsigned" implies "> 0"?
Product: clang
Version: 7.0
Hardware: PC
OS: FreeBSD
Status: NEW
Severity: enhancement
Priority: P
Component: Static Analyzer
Assignee: dcoughlin at apple.com
Reporter: cperciva at freebsd.org
CC: dcoughlin at apple.com, llvm-bugs at lists.llvm.org
Created attachment 21147
--> https://bugs.llvm.org/attachment.cgi?id=21147&action=edit
test case
The attached source file (scan-build-fp.c) has two assertions; the first
asserts that an expression is > a size_t variable, while the second is hidden
behind #ifdef SCAN_BUILD_IS_STUPID and asserts that the same expression is > 0.
It should be trivial to deduce that anything which is greater than an unsigned
value must be greater than zero, but scan-build fails to do this and yields a
false positive warning unless the > 0 condition is separately asserted:
$ scan-build70 cc -c scan-build-fp.c
scan-build: Using '/usr/local/llvm70/bin/clang-7' for static analysis
scan-build-fp.c:85:3: warning: Null pointer argument in call to memory copy
function
memcpy((uint8_t *)(EA->buf) + bufpos, buf, nbytes);
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
1 warning generated.
scan-build: 1 bug found.
scan-build: Run 'scan-view /tmp/scan-build-2018-11-24-063313-4294-1' to examine
bug reports.
$ scan-build70 cc -c scan-build-fp.c -DSCAN_BUILD_IS_STUPID
scan-build: Using '/usr/local/llvm70/bin/clang-7' for static analysis
scan-build: Removing directory '/tmp/scan-build-2018-11-24-063309-4282-1'
because it contains no reports.
scan-build: No bugs found.
--
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/20181124/9f153693/attachment.html>
More information about the llvm-bugs
mailing list