[LLVMbugs] [Bug 13107] New: The warning: "property attributes 'readonly' and 'copy' are mutually exclusive" doesn't make sense

bugzilla-daemon at llvm.org bugzilla-daemon at llvm.org
Wed Jun 13 09:38:21 PDT 2012


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

             Bug #: 13107
           Summary: The warning: "property attributes 'readonly' and
                    'copy' are mutually exclusive" doesn't make sense
           Product: clang
           Version: trunk
          Platform: All
        OS/Version: All
            Status: NEW
          Severity: normal
          Priority: P
         Component: -New Bugs
        AssignedTo: unassignedclangbugs at nondot.org
        ReportedBy: remy.demarest at gmail.com
                CC: llvmbugs at cs.uiuc.edu
    Classification: Unclassified


Summary:
When making a property which declares both copy and readonly attribute, a
warning appearing saying they are mutually exclusive.

Steps to Reproduce:
1) Turn on -Weverything
2) write the property @property(copy, readonly) NSString *prop;

Expected Results:
It should just work without warning

Actual Results:
Displays the result "property attributes 'readonly' and 'copy' are mutually
exclusive"

Regression:

Notes:
This warning is broken because it prevents a perfectly valid paradigm from
working. Any readonly property you declare has the capacity to be overridden
either in a class extension or a subclass to replace readonly with readwrite.
If readonly and copy can't work together than you cannot have a readwrite
equivalent that actually needs the copy attribute. This is especially
problematic with classes like NSString or NSArray that have mutable subclasses
and where retain/strong cannot be used without encapsulation problems.

This issue is related to this one: rdar://9396329/ which was closed without
being corrected.

Here is an impossible problem to resolve without warnings:

@interface MyClass : NSObject
@property(copy, readonly) NSString *prop; // Warning appears here
@end

@interface MyClass ()
@property(copy, readwrite) NSString *prop; // Private setter
@end

@implementation MyClass
@synthesize prop;
@end

If we resolve the top warning:

@interface MyClass : NSObject
@property(readonly) NSString *prop; // No warning
@end

@interface MyClass ()
@property(copy, readwrite) NSString *prop; // Unmatched property attributes
@end

@implementation MyClass
@synthesize prop; // Error under ARC (unspecified ownership)
@end

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