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: [email protected]
        ReportedBy: [email protected]
                CC: [email protected]


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.
_______________________________________________
LLVMbugs mailing list
[email protected]
http://lists.cs.uiuc.edu/mailman/listinfo/llvmbugs

Reply via email to