test expr-22.8 should not be knownBug
Closed / Fixed584825ffffffffffffffffffffffffffffffffffCreated 24 years agoUpdated 24 years ago
Descriptionplain2002-07-22 10:10:37
On Solaris8/SPARC, the test expr-22.8 fails because of a parser overrun (experiment shows that the object passed to IllegalExprOperandType() has length 4 and bytes "Inf}" which is wrong and unexpected.) Why is the parser running on past the end of the argument passed to [expr]? For the moment, because I know of no way to exploit this bug, I've marked that test as knownBug, but I'm not at all happy with that...
dgpplain2002-07-22 23:30:42
Logged In: YES user_id=80530 This appears to trace back to a difference of opinion about how strtod() is supposed to be implemented. In particular, when given the 4 bytes 'I', 'n', 'f', and '\0', how many bytes should strtod claim make up the valid double value? Thus what should the endPtr be set to? Solaris strtod() claims that '\0' is part of the string rep of the double, so it sets endPtr to point one past the null. Linux strtod() claims that '\0' is not part of the double, so it sets endPtr to point at the '\0'. Later that character gets turned back into '}' like it was before. It seems very strange to me that the Solaris strtod() handles the string "NaN" differently, and does not claim the trailing '\0' for it. FWIW, the compat/strtod.c offered with the Tcl sources recognizes neither Inf nor Nan. Finally, note that on Linux, the test expr-22.8 fails for a different reason. There, the string "Inf" is happily converted to a legal double by Tcl_GetDoubleFromObj() on line 3112 of tclExecute.c. So, Tcl goes ahead and performs the 1 / Inf calculation and gets the correct answer: 0.0
dkfplain2002-07-30 22:33:59
Logged In: YES user_id=79902 It seems that handling of Inf and NaN varies quite a bit between platforms. :^( Looks like I'll have to mark this group of tests as nonPortable...
dkfplain2002-07-31 16:41:56
Logged In: YES user_id=79902 Marked all this set of tests as non-portable as I'm not aware yet of any pair of platforms which give the same answers. :^/ Left bug open because the whole issue needs fixing (including more satisfactory resolutions of bugs 584950 and 585986)
dkfplain2002-07-31 17:27:20
Logged In: YES user_id=79902 Turns out that fixstrtod() already handles this sort of thing, but the test for when to enable it was poor.
Log in (anonymous is fine) to add a comment.