[Issue 1219] New: long.max.stringof gets corrupted

d-bugmail at puremagic.com d-bugmail at puremagic.com
Mon May 7 07:31:43 PDT 2007


http://d.puremagic.com/issues/show_bug.cgi?id=1219

           Summary: long.max.stringof gets corrupted
           Product: D
           Version: 1.014
          Platform: PC
        OS/Version: Linux
            Status: NEW
          Keywords: wrong-code
          Severity: normal
          Priority: P2
         Component: DMD
        AssignedTo: bugzilla at digitalmars.com
        ReportedBy: fvbommel at wxs.nl


See the comments for stuff that makes the problem go away:
---
import std.stdio;
import std.string;

// "Manually" instantiating this template function (changing it into
// a regular function with void[0] argument) makes the problem disappear.
void foo(T)(T t) {
    /*
    // It even fails if this is put in (so below code isn't reached).
    return null;
    //*/

    // It works if this is removed:
    static if (is(typeof(T.nonexistant)))
    {}
}

void main() {
    /*
    // Shows that long.max.stringof is wrong:
    writefln(long.max);
    writefln(long.max.stringof);
    //*/

    /*
    // Shows the problem more exactly:
    // (namely, the first 2 bytes of long.max.stringof are wrong)
    foreach(char c; format(long.max)) {
            writef("%02x ", c);
    }
    writefln();
    foreach(char c; long.max.stringof) {
            writef("%02x ", c);
    }
    writefln();
    //*/

    assert(long.max.stringof == format(long.max));      // fails

    // Remove this or change the argument to something
    // other than a static array and it works.
    foo([]);
}
---


-- 



More information about the Digitalmars-d-bugs mailing list