Learn how easy it is to sync an existing GitHub or Google Code repo to a SourceForge project! See Demo

Close

#1989 test expr-22.8 should not be knownBug

obsolete: 8.4b2
closed-fixed
5
2002-07-31
2002-07-22
Donal K. Fellows
No

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...

Discussion

  • Don Porter
    Don Porter
    2002-07-22

    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

     
    • priority: 8 --> 9
    • assigned_to: dgp --> dkf
     
  • 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...

     
  • 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)

     
    • priority: 9 --> 5
     
    • status: open --> closed-fixed
     
  • 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.