XQueryNumber: returns double when asked for float ARC/64(Clang / 64-bit / ARC)

Originator:wil.shipley
Number:rdar://10924655 Date Originated:23-Feb-2012 07:29 PM
Status:Open Resolved:
Product:Mac OS X Product Version:10.7.3
Classification:Crasher / Data loss Reproducible:YES
 
I discovered after calling XQuery to get to some floats out of a XML document that the float values were being corrupted when stored in CoreData.

Upon debugging, it turns out that the private “XQueryNumber” (NSNumber subclass) returns a DOUBLE value when you ask it for a FLOAT, which causes garbage results.

Check it:

(gdb) po [$1 class]
XQueryNumber

(gdb) po $1
0.6

(gdb) p (double)[$1 doubleValue]
$10 = 0.59999999999999998

(gdb) p (float)[$1 floatValue]
$9 = 4.17232506e-08

(gdb) p (double)[$1 floatValue]
$11 = 0.59999999999999998


Our program is compiled with ARC and is 64-bit only, running the Clang that is on Xcode 4.3 final.

Comments


Please note: Reports posted here will not necessarily be seen by Apple. All problems should be submitted at bugreport.apple.com before they are posted here. Please only post information for Radars that you have filed yourself, and please do not include Apple confidential information in your posts. Thank you!