Created
March 12, 2015 18:56
-
-
Save tjw/b69773a1e0950a3be4ee to your computer and use it in GitHub Desktop.
20140181: Regression: clang static analyzer emits spurious warning when releasing strong ivar in -dealloc
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#import <Foundation/Foundation.h> | |
/* | |
clang --analyze readonly-property-analyzer.m | |
readonly-property-analyzer.m:20:2: warning: Incorrect decrement of the reference count of an object that is not owned at this point by the caller | |
[_string release]; | |
^~~~~~~~~~~~~~~~~ | |
1 warning generated. | |
NOTE: If the properties is changed to include 'strong', this problem goes away (though not my fear that in ARC mode the compiler is now defaulting object-typed properties to be non-strong). | |
*/ | |
@interface Foo : NSObject | |
- initWithString:(NSString *)string; | |
@property(nonatomic,strong,readonly) NSString *string; | |
@end | |
@implementation Foo | |
- initWithString:(NSString *)string; | |
{ | |
if (!(self = [super init])) | |
return nil; | |
_string = [string copy]; | |
return self; | |
} | |
- (void)dealloc; | |
{ | |
[_string release]; | |
[super dealloc]; | |
} | |
@end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment