Created
May 24, 2021 15:43
-
-
Save douglashill/cf9c3839f76db5ac5351e695fd493fd0 to your computer and use it in GitHub Desktop.
Sending a message to nil is supposed to do nothing in Objective-C, but here it’s changing the local variable error to nil. Tested with Xcode 12.5 on macOS 11.3.1.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
NSError *error = [NSError errorWithDomain:@"domain" code:123 userInfo:nil]; | |
[(NSFileHandle *)nil seekToOffset:0 error:&error]; | |
assert(error != nil); // 💥 Not OK. The error has gone! |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Works correctly for me:
cc -o msgnil msgnil.m -framework Cocoa && ./msgnil
got here