D issues are now tracked on GitHub. This Bugzilla instance remains as a read-only archive.
Issue 5624 - std.conv unittest disabled
Summary: std.conv unittest disabled
Status: RESOLVED FIXED
Alias: None
Product: D
Classification: Unclassified
Component: dmd (show other issues)
Version: D2
Hardware: x86_64 Linux
: P2 critical
Assignee: No Owner
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2011-02-20 14:19 UTC by Brad Roberts
Modified: 2011-11-28 22:01 UTC (History)
0 users

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this issue.
Description Brad Roberts 2011-02-20 14:19:56 UTC
the debug version passes
the release version segvs
Comment 1 Brad Roberts 2011-05-01 02:04:56 UTC
reduced case.  Requires -m64 and -O.  Without -O it passes:

module bug;

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

wstring toImpl(int value)
{
    wchar[13] buffer;

    auto u = -cast(int) value;
    uint ndigits = 1;
    while (u)
    {  
        immutable c = cast(char)((u % 10) + '0');
        u /= 10;
        buffer[$ - ndigits] = c;
        ++ndigits;
    }
    assert(ndigits <= buffer.length);
    buffer[$ - ndigits] = '-';
    //printf("ndigits = %d, buffer.length = %zd, diff = %d\n", ndigits, buffer.length, buffer.length - ndigits);
    return cast(wstring) buffer[buffer.length - ndigits .. buffer.length].dup;
}

int main()
{
    wstring s = toImpl(int.min);
    return 0;
}

Uncommenting the printf results in:
    Illegal instruction

from objdump --disassemble:
  fe:   66 48 c7 06 2d 00 48    data32 movq $0xffffffff8948002d,(%rsi)
 105:   89 
 106:   d9 48 ba                (bad)  -0x46(%rax)
 109:   0d 00 00 00 00          or     $0x0,%eax

from obj2asm:

00fe:   66 48 C7 06 2D 00       mov     qword ptr [RSI],02Dh
0104:   48 89 D9                mov     RCX,RBX
0107:   48 BA 0D 00 00 00 00 00 00 00   mov     RDX,0Dh
0111:   48 89 75 D0             mov     -030h[RBP],RSI

0x2d == '-'.  This is part of the buffer[$ - ndigits] = '-' line.