Skip to content

Instantly share code, notes, and snippets.

@boredzo
Created February 15, 2013 23:52
Show Gist options
  • Select an option

  • Save boredzo/4964590 to your computer and use it in GitHub Desktop.

Select an option

Save boredzo/4964590 to your computer and use it in GitHub Desktop.
Initialization of block pointer variable with incompatible block using wrong syntax passes without error or warning
#import <Foundation/Foundation.h>
int main(int argc, char *argv[]) {
@autoreleasepool {
/*Note the use of Objective-C method-style return type syntax.
*That's not actually the correct syntax, but the incorrect syntax passes compilation
*without a warning even though these blocks have different and incompatible signatures!
*/
id (^wat)(int x, int y) = (id)^(CGFloat x, CGFloat y) {
return @(hypot(x, y));
};
NSLog(@"Expected result: %f", hypot(640, 480));
NSLog(@"Actual result: %@", wat(640, 480));
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment