Thread overview
[Issue 5625] New: std.format unittest disabled
Feb 20, 2011
Brad Roberts
Mar 20, 2011
Brad Roberts
Mar 20, 2011
Brad Roberts
Jan 02, 2012
Brad Roberts
Feb 26, 2012
yebblies
Mar 04, 2013
Don
February 20, 2011
http://d.puremagic.com/issues/show_bug.cgi?id=5625

           Summary: std.format unittest disabled
           Product: D
           Version: D2
          Platform: x86_64
        OS/Version: Linux
            Status: NEW
          Severity: critical
          Priority: P2
         Component: DMD
        AssignedTo: nobody@puremagic.com
        ReportedBy: braddr@puremagic.com


--- Comment #0 from Brad Roberts <braddr@puremagic.com> 2011-02-20 14:21:04 PST ---
Testing generated/linux/debug/64/unittest/std/format core.exception.AssertError@std.format(3651): unittest failure

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
March 20, 2011
http://d.puremagic.com/issues/show_bug.cgi?id=5625



--- Comment #1 from Brad Roberts <braddr@puremagic.com> 2011-03-20 03:21:43 PDT ---
Here's the reduced version of this bug.  Larger than I'd like still, but is proving hard to reduce further.

module bug;

extern(C) int printf(const char *, ...);

struct FormatSpec
{
    char spec = 's';
    bool flHash = false;

    // unused function, but if removed hides the bug
    void writeUpToNextSpec(OutputRange)(OutputRange writer) {}
}

void formatValue(long val, ref FormatSpec f)
{
    char[] w;
    long arg = val;

    // always true, but removing conditional hides the bug
    uint base = f.spec == 's' ? 10 : 0;

    // if moved above base line, or merged with the declaration, hides the bug
    arg = -arg;

    char buffer[64]; // 64 bits in base 2 at most
    uint i = buffer.length;
    auto n = cast(ulong) arg;
    do
    {
        --i;
        buffer[i] = cast(char) (n % base);
        n /= base;
        if (buffer[i] < 10)
            buffer[i] += '0';
        else
            buffer[i] += 'A' - 10;
    }
    while (n);

    // unused, but if removed hides the bug;
    sizediff_t spacesToPrint = (base == 16 && f.flHash && arg);

    // always true, but needs the conditional to show the bug
    if (arg)
        w = buffer[i .. $];

    // the code to append the '-' to w was removable, so '999'
    // really is the expected results
    printf("w = %.*s\n", w.length, w.ptr);
    assert(w == "999");
}

int main()
{
    auto spec = FormatSpec();

    formatValue(-999L, spec);

    return 0;
}

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
March 20, 2011
http://d.puremagic.com/issues/show_bug.cgi?id=5625



--- Comment #2 from Brad Roberts <braddr@puremagic.com> 2011-03-20 03:35:07 PDT ---
For that reduction, it needs both -m64 and -O to fail.

Also, this likely isn't the only 64 bit bug related to std.format.  I'm not sure why, but the reduction in comment 1 isn't the same as the line number in comment 0 points to.  The one at line 3651 didn't fail for me when I started reducing the bug but is right now.

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
January 02, 2012
http://d.puremagic.com/issues/show_bug.cgi?id=5625



--- Comment #3 from Brad Roberts <braddr@puremagic.com> 2012-01-01 21:02:22 PST ---
The bug in comment 1 has been fixed.  The next bug related to creal passing in vararg's.  The repro case:

module bugformat;

import core.vararg;

void bar(TypeInfo[] arguments, va_list argptr)
{
    creal values = va_arg!(cdouble)(argptr);
    assert(values == 1.2 + 3.4i, "value didn't make it through intact");
}

void foo(...)
{
    bar(_arguments, _argptr);
}

int main()
{
    foo(1.2 + 3.4i);

    return 0;
}

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
February 26, 2012
http://d.puremagic.com/issues/show_bug.cgi?id=5625


yebblies <yebblies@gmail.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
           Keywords|                            |wrong-code
                 CC|                            |yebblies@gmail.com
         AssignedTo|nobody@puremagic.com        |yebblies@gmail.com


--- Comment #4 from yebblies <yebblies@gmail.com> 2012-02-27 03:36:47 EST ---
I think I've got this.  The complex xmm codegen is pretty awful.

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
December 09, 2012
http://d.puremagic.com/issues/show_bug.cgi?id=5625



--- Comment #5 from github-bugzilla@puremagic.com 2012-12-08 19:42:09 PST ---
Commit pushed to master at https://github.com/D-Programming-Language/phobos

https://github.com/D-Programming-Language/phobos/commit/9db098b69a7c2057152a6940cac368264a5e0869 [Fixup] Now, bug 5625 might not be directly related to std.string.format

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
March 04, 2013
http://d.puremagic.com/issues/show_bug.cgi?id=5625


Don <clugdbug@yahoo.com.au> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|NEW                         |RESOLVED
         Resolution|                            |FIXED


--- Comment #6 from Don <clugdbug@yahoo.com.au> 2013-03-04 01:46:48 PST ---
The original bug in this report has been fixed. I've moved the independent bug reported in comment 3 into a new bug 9643.

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------