[cfe-dev] [PATCH]es: Objective-C lightweight generics

David Chisnall David.Chisnall at cl.cam.ac.uk
Wed Jul 8 00:29:32 PDT 2015


On 7 Jul 2015, at 17:28, Douglas Gregor <dgregor at apple.com> wrote:
> 
>> Would there be interest in a compilation mode that inserted run-time checks for these cases?  We discussed previously doing it on every down cast and cast-from-id in Objective-C, but came to the conclusion that the false positive rate would be too high.  For generics, I suspect that people either want to not break the rules, or will just use the non-generic version.
> 
> My general impression here is that people will still want to break the rules, e.g., by continuing to use proxies that don't properly implement -isKindOfClass:, so I’ve not pursued this.

My thought was that it would behave in the same way as some of the other non-fatal errors in Objective-C, printing a message along the lines of “*** Cast from Foo to Bar disallowed by generics.  Put breakpoint on objc_generics_whatever() to debug”.  You’d turn this off in production, but when debugging (-fsanitize=objc-generics?) you’d be able to catch it early.

David





More information about the cfe-dev mailing list