www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.bugs - [Issue 5625] New: std.format unittest disabled

reply d-bugmail puremagic.com writes:
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



---
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: -------
Feb 20 2011
next sibling parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=5625




---
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: -------
Mar 20 2011
prev sibling next sibling parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=5625




---
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: -------
Mar 20 2011
prev sibling next sibling parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=5625




---
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: -------
Jan 01 2012
prev sibling next sibling parent d-bugmail puremagic.com writes:
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



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: -------
Feb 26 2012
prev sibling next sibling parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=5625




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: -------
Dec 08 2012
prev sibling parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=5625


Don <clugdbug yahoo.com.au> changed:

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



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: -------
Mar 04 2013