[LLVMbugs] [Bug 9063] New: -Wuninitialized false positive due to |int var; if (get(&var)) use(var); | pattern

bugzilla-daemon at llvm.org bugzilla-daemon at llvm.org
Wed Jan 26 16:58:05 PST 2011


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

           Summary: -Wuninitialized false positive due to |int var; if
                    (get(&var)) use(var);| pattern
           Product: clang
           Version: trunk
          Platform: PC
        OS/Version: All
            Status: NEW
          Severity: normal
          Priority: P
         Component: Static Analyzer
        AssignedTo: kremenek at apple.com
        ReportedBy: nicolasweber at gmx.de
                CC: llvmbugs at cs.uiuc.edu


In many places, chrome uses code that looks like this:

  for(..) {
    double expiry;
    if (!state->GetReal("expiry", &expiry)) {
      continue;
    }
    base::Time expiry_time = base::Time::FromDoubleT(expiry);
  }

GetReal will write to expiry if it returns true. clang complains:



/Volumes/MacintoshHD2/src/chrome-git/src/net/base/transport_security_state.cc:316:5:
error: use of uninitialized variable 'expiry' [-Wuninitialized]
    double expiry;
    ^~~~~~~~~~~~~
/Volumes/MacintoshHD2/src/chrome-git/src/net/base/transport_security_state.cc:337:54:
note: variable 'expiry' is possibly uninitialized when used here
    base::Time expiry_time = base::Time::FromDoubleT(expiry);
                                                     ^~~~~~
/Volumes/MacintoshHD2/src/chrome-git/src/net/base/transport_security_state.cc:316:18:
note: add initialization to silence this warning
    double expiry;
                 ^
                  = 0.0
1 error generated.




This causes many many false positives in the chrome codebase.

-- 
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