[LLVMbugs] [Bug 15836] New: Analyzer doesn't know sizeof(id)==sizeof(NSObject *), causes false +ve

bugzilla-daemon at llvm.org bugzilla-daemon at llvm.org
Wed Apr 24 05:52:49 PDT 2013


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

            Bug ID: 15836
           Summary: Analyzer doesn't know sizeof(id)==sizeof(NSObject *),
                    causes false +ve
           Product: clang
           Version: 3.2
          Hardware: PC
                OS: All
            Status: NEW
          Severity: normal
          Priority: P
         Component: Static Analyzer
          Assignee: kremenek at apple.com
          Reporter: iamleeg at gmail.com
                CC: llvmbugs at cs.uiuc.edu
    Classification: Unclassified

This is tested with Xcode 4.6.2's analyzer, I haven't had the opportunity to
test with clang trunk yet.

Test case:

#import <Foundation/Foundation.h>

int main(int argc, const char * argv[])
{

    @autoreleasepool {
        __unsafe_unretained NSObject **objectArray = (__unsafe_unretained
NSObject **)malloc(sizeof(id) * 10);
        free(objectArray);
    }
    return 0;
}


Actual result:

Result of 'malloc' is converted to a pointer of type 'NSObject
*__unsafe_unretained', which is incompatible with sizeof operand type 'id'

Expected result:

There shouldn't be an issue. The type outside the malloc() call is a pointer to
an object of the same size as the type inside the sizeof() macro—a pointer to
an Objective-C object.

Workaround:

change the type inside sizeof to "NSObject *". This suppresses the analyzer
report, which specifically occurs when the analyzer compares 'id' to a typed
ObjC object pointer.

-- 
You are receiving this mail because:
You are on the CC list for the bug.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-bugs/attachments/20130424/8f796287/attachment.html>


More information about the llvm-bugs mailing list