[LLVMbugs] [Bug 9283] New: [C++] False positive: uninitialized but passed as ref arg to a member function.

bugzilla-daemon at llvm.org bugzilla-daemon at llvm.org
Mon Feb 21 14:06:10 PST 2011


http://llvm.org/bugs/show_bug.cgi?id=9283

           Summary: [C++] False positive: uninitialized but passed as ref
                    arg to a member function.
           Product: clang
           Version: trunk
          Platform: PC
        OS/Version: All
            Status: NEW
          Severity: normal
          Priority: P
         Component: Static Analyzer
        AssignedTo: kremenek at apple.com
        ReportedBy: devlists at shadowlab.org
                CC: llvmbugs at cs.uiuc.edu


Created an attachment (id=6203)
 --> (http://llvm.org/bugs/attachment.cgi?id=6203)
reduced test case

When passing a variable as reference to a member function, clang does not
consider it is initialized and warn about garbage when using it afterward.
Note that it look like this false positive occurs only when the function is a
member function. When it is just declared outside of a class, clang does not
print any warning.

-------------- member-ref.cpp
class AtomStream {
public:
  bool ReadUInt32(int &value);
};

bool test(AtomStream& box) {  
  int type;
  box.ReadUInt32(type);
  return type != 0;
}

---------------
% clang++ --analyze member-ref.cpp
member-ref.cpp:10:15: warning: The left operand of '!=' is a garbage value
  return type != 0;
         ~~~~ ^
1 warning generated.

-- 
Configure bugmail: http://llvm.org/bugs/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are on the CC list for the bug.



More information about the llvm-bugs mailing list