When compiled with ARC, the return value from invoking origImps[X] is passed into objc_retain() because IMP is assumed to return an id value. For [NSURLConnection alloc] and [NSURLConnection sendSynchronousRequest:returningResponse:error:] this is correct behavior. [NSURLConnection sendAsynchronousRequest:queue:completionHandler:] however returns void. In this case, ARC's auto-generated objc_retain() is passed in a junk pointer to whatever was hanging around in the retval register, causing a crash.
This commit casts the IMP to a strongly typed function pointer that has a void return type, which gives the compiler enough information to suppress the generation of an objc_retain() call on the retval.