[llvm-bugs] [Bug 36953] New: False positive: Undefined or garbage value returned to caller

via llvm-bugs llvm-bugs at lists.llvm.org
Fri Mar 30 00:54:55 PDT 2018


https://bugs.llvm.org/show_bug.cgi?id=36953

            Bug ID: 36953
           Summary: False positive: Undefined or garbage value returned to
                    caller
           Product: clang
           Version: 6.0
          Hardware: PC
                OS: Linux
            Status: NEW
          Severity: normal
          Priority: P
         Component: Static Analyzer
          Assignee: dcoughlin at apple.com
          Reporter: vlad.bespalov at jetstreamsoft.com
                CC: llvm-bugs at lists.llvm.org

Created attachment 20143
  --> https://bugs.llvm.org/attachment.cgi?id=20143&action=edit
minimal reproducer

possibly same origin as bug 16021 as it is about comparing 2 variables.

Full reproducer is attached.
-------------
// reproducer has an uninited status var
int status, a, b;
// prepare a & b
while (a < b) {
   //modify a
   if (break condition) {
       status = -1;
       break;
   }
}
// we arrive here due to while condition is false or because of the break;
if (! (a < b)) {
    status = 1;
}

// this line triggers the warning.
return status;
-----------

clang-check is called as

$ clang-check stupid.c -analyze -extra-arg -Xanalyzer -extra-arg
-analyzer-output=text

Also the notes describing the path issue in the clang-check output are:
------------
/home/Vlad.Bespalov/source/!9/stupid.c:5:5: note: Loop condition is false.
Execution continues on line 13
    while (sent < len) {
    ^
/home/Vlad.Bespalov/source/!9/stupid.c:13:5: note: Taking false branch
    if (! (sent < len)) {
    ^
------------
which is obviously wrong.

clang-check version:
------------
$ clang-check --version
LLVM (http://llvm.org/):
  LLVM version 6.0.0
  Optimized build.
  Default target: x86_64-unknown-linux-gnu
  Host CPU: amdfam10
------------

-- 
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/20180330/f3ed49a6/attachment.html>


More information about the llvm-bugs mailing list