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

Reply via email to