[Issue 8796] New: Optimizer bug on 64bit
d-bugmail at puremagic.com
d-bugmail at puremagic.com
Wed Oct 10 14:37:26 PDT 2012
http://d.puremagic.com/issues/show_bug.cgi?id=8796
Summary: Optimizer bug on 64bit
Product: D
Version: unspecified
Platform: x86_64
OS/Version: All
Status: NEW
Severity: critical
Priority: P2
Component: DMD
AssignedTo: nobody at puremagic.com
ReportedBy: dmitry.olsh at gmail.com
--- Comment #0 from Dmitry Olshansky <dmitry.olsh at gmail.com> 2012-10-10 14:13:18 PDT ---
Uncovered while doing a re-write for std.array.insertInPlace.
It got caught by pull auto-tester.
Sample:
import std.conv, std.utf;
void insertInPlace(T, U...)(ref T[] array, size_t pos, U stuff)
{
{// mutable, can do in place
//helper function: re-encode dchar to Ts and store at *ptr
static T* putDChar(T* ptr, dchar ch)
{
static if(is(T == dchar))
{
*ptr++ = ch;
return ptr;
}
else
{
T[dchar.sizeof/T.sizeof] buf;
size_t len = encode(buf, ch);
final switch(len)
{
static if(T.sizeof == char.sizeof)
{
case 4:
ptr[3] = buf[3];
goto case;
case 3:
ptr[2] = buf[2];
goto case;
}
case 2:
ptr[1] = buf[1];
goto case;
case 1:
ptr[0] = buf[0];
}
ptr += len;
return ptr;
}
}
immutable oldLen = array.length;
size_t to_insert = 0;
foreach (i, E; U)
to_insert += codeLength!T(stuff[i]);
array.length += to_insert;
auto ptr = array.ptr + pos;
foreach (i, E; U)
{
static if(is(E : dchar))
{
ptr = putDChar(ptr, stuff[i]);
}
else
{
foreach (dchar ch; stuff[i])
ptr = putDChar(ptr, ch);
}
}
assert(ptr == array.ptr + pos + to_insert, text(ptr - array.ptr, " vs
",pos+ to_insert ));
}
}
void main()
{
auto l = "hello"d.dup;
auto r = " વિશ્વ".dup;
l.insertInPlace(0, r);
}
Compiled as
dmd -O atest.d
It fails with:
core.exception.AssertError at atest.d(75): 0 vs 6
Compiled without -O it doesn't fail. It also works fine in 32 bits.
Tested with dmd 2.061 from github. Commit
a1287bd0b1931917f4e43b5e2d7b997f0d60adf6.
--
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
More information about the Digitalmars-d-bugs
mailing list