#1989 test expr-22.8 should not be knownBug

obsolete: 8.4b2

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


  • Don Porter

    Don Porter - 2002-07-22

    Logged In: YES

    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

  • Donal K. Fellows

    • priority: 8 --> 9
    • assigned_to: dgp --> dkf
  • Donal K. Fellows

    Logged In: YES

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

  • Donal K. Fellows

    Logged In: YES

    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

  • Donal K. Fellows

    • priority: 9 --> 5
  • Donal K. Fellows

    • status: open --> closed-fixed
  • Donal K. Fellows

    Logged In: YES

    Turns out that fixstrtod() already handles this sort of
    thing, but the test for when to enable it was poor.


Get latest updates about Open Source Projects, Conferences and News.

Sign up for the SourceForge newsletter:

No, thanks