[cfe-commits] [patch] Retain/release checking for ObjCStringLiterals

Jordan Rose jediknil at belkadan.com
Mon Mar 12 09:44:56 PDT 2012


On Mar 12, 2012, at 1:44, Jean-Daniel Dupas wrote:

> Le 11 mars 2012 à 22:37, Jordan Rose a écrit :
> 
>> After I complained about it a few days ago, I figured I'd take a stab at fixing this:
>> 
>> [@"abc" release]; // should warn!
> 
> I'm not sure I agree it should warn. It is a well known fact that retain/release are noop on constant string literal and it is used in many place.
> 
> IHMO, the static analyzer should continue to ignore String literals as it actually does.

Hm. I don't like it cause it smells like bad style to me, but you're right; I forgot that this was documented behavior:

> The compiler makes such object constants unique on a per-module basis, and they’re never deallocated, though you can retain and release them as you do any other object.

(from Apple's String Programming Guide)

So maybe the contortions necessary to get it working aren't worth it.





More information about the cfe-commits mailing list