[LLVMbugs] [Bug 9064] New: -Wuninitialized doesn't understand ObjC2 loops

bugzilla-daemon at llvm.org bugzilla-daemon at llvm.org
Wed Jan 26 17:01:12 PST 2011


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

           Summary: -Wuninitialized doesn't understand ObjC2 loops
           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


code:

  for (NSString* mime_type in [mime_types allKeys]) {
    NSDictionary* mime_dict = [mime_types objectForKey:mime_type];
    NSString* mime_desc = [mime_dict objectForKey:@"WebPluginTypeDescription"];
    NSArray* mime_exts = [mime_dict objectForKey:@"WebPluginExtensions"];

    WebPluginMimeType mime;
    mime.mime_type = base::SysNSStringToUTF8([mime_type lowercaseString]);
    // Remove PDF from the list of types handled by QuickTime, since it
provides
    // a worse experience than just downloading the PDF.
    if (mime.mime_type == "application/pdf" &&
        StartsWithASCII(filename.BaseName().value(), "QuickTime", false)) {
      continue;
    }
  }


clang suggests:


/Volumes/MacintoshHD2/src/chrome-git/src/webkit/support/../plugins/npapi/plugin_lib_mac.mm:88:8:
error: use of uninitialized variable 'mime_type' [-Wuninitialized]
  for (NSString* mime_type in [mime_types allKeys]) {
       ^~~~~~~~~~~~~~~~~~~
/Volumes/MacintoshHD2/src/chrome-git/src/webkit/support/../plugins/npapi/plugin_lib_mac.mm:89:56:
note: variable 'mime_type' is possibly uninitialized when used here
    NSDictionary* mime_dict = [mime_types objectForKey:mime_type];
                                                       ^~~~~~~~~
/Volumes/MacintoshHD2/src/chrome-git/src/webkit/support/../plugins/npapi/plugin_lib_mac.mm:88:27:
note: add initialization to silence this warning
  for (NSString* mime_type in [mime_types allKeys]) {
                          ^
                           = nil


Yikes!

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