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

            Bug ID: 39032
           Summary: Static Analyzer false positive: initialized value is
                    believed to be uninitialized
           Product: clang
           Version: trunk
          Hardware: PC
                OS: Linux
            Status: NEW
          Severity: enhancement
          Priority: P
         Component: Static Analyzer
          Assignee: [email protected]
          Reporter: [email protected]
                CC: [email protected]

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

In the attached example, Static Analyzer claims that a value which is
definitely initialized is not. Determining _what_ it is initialized to might be
a more difficult exercise, but it certainly is not uninitialized.

clang -cc1 -analyze -analyzer-checker=core sa.c

sa.c:10:3: warning: 1st function call argument is an uninitialized value
  fn(ptr[1]);  
  ^~~~~~~~~~

If we try to access ptr[0] instead, the warning goes away.

I suspect this might be due to deficiencies in RegionStore. SA knows that ptr
points to str, but it cannot seem to locate the binding to str through an
ElementRegion with an offset of 1.

I'd fix this myself, but I don't know if this is a problem with how RegionStore
looks up the bindings, either in getBindingForElement or
getBindingForFieldOrElementCommon, or if it's a problem with how it registers
the binding of str. Or something completely different altogether.

-- 
You are receiving this mail because:
You are on the CC list for the bug.
_______________________________________________
llvm-bugs mailing list
[email protected]
http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-bugs

Reply via email to