• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
LLVM : spurious memory-mgmt warnings with "Copy" methods
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

LLVM : spurious memory-mgmt warnings with "Copy" methods


  • Subject: LLVM : spurious memory-mgmt warnings with "Copy" methods
  • From: Jerry Krinock <email@hidden>
  • Date: Tue, 13 Dec 2011 22:33:34 -0800

Apple LLVM 3.0 compiler does not recognize that my methods with "Copy" in their name live by different memory-management rules.

Example…

- mutableDeepCopyStyle:(SSYDeepCopyStyleBitmask)style {
    NSMutableSet *newSet = [[NSMutableSet alloc] init];
    for (id object in self) {
        id copy = [object mutableDeepCopyStyle:style] ;
        [newSet addObject:copy];
        [copy release];  // LLVM Warning #1
    }
    return newSet; // LLVM Warning #2
}

LLVM Warnings
#1.  Incorrect decrement of the reference count of an object that is not owned at this point by the caller
#2.  Potential leak of an object stored into 'newSet'

I think that Warning #1 is spurious because I'm releasing an object which was obtained from a 'Copy' method, which is correct.  And Warning #2 is spurious because the method has 'Copy' in its name, therefore returning a retained object is expected.

What is the correct way to fix these warnings?

Thanks,

Jerry Krinock


 _______________________________________________
Do not post admin requests to the list. They will be ignored.
Xcode-users mailing list      (email@hidden)
Help/Unsubscribe/Update your Subscription:

This email sent to email@hidden

  • Follow-Ups:
    • Re: LLVM : spurious memory-mgmt warnings with "Copy" methods
      • From: Jens Alfke <email@hidden>
  • Prev by Date: Re: __bridge cast on CF object stored in NSDictionary?
  • Next by Date: Re: LLVM : spurious memory-mgmt warnings with "Copy" methods
  • Previous by thread: Re: __bridge cast on CF object stored in NSDictionary?
  • Next by thread: Re: LLVM : spurious memory-mgmt warnings with "Copy" methods
  • Index(es):
    • Date
    • Thread