Description
Bugzilla Link | 13640 |
Resolution | MOVED |
Resolved on | Aug 19, 2012 10:06 |
Version | 3.1 |
OS | MacOS X |
Attachments | test case |
Reporter | LLVM Bugzilla Contributor |
CC | @lattner |
Extended Description
The Objective-C literals @true and @false result at runtime in NSNumber objects with incorrect type-encodings. The objects claim to be integers, not BOOLs (encoding "i", not "c".)
This has serious side effects: in particular, NSJSONSerialization doesn't realize these objects are supposed to be booleans, so it encodes them in JSON as "0" and "1", not "false" and "true". That's how I discovered this problem -- after "modernizing" my code to use @true and @false, the CouchDB server it communicates with started failing with HTTP 500 errors, because a parameter was being sent as an integer instead of a boolean.
Note that @true isn't even compatible with kCFBooleanTrue or [NSNumber numberWithBool: YES], both of which generate type encoding "c".
Attached is a short test case that demonstrates the problem.