Bug 5549 – [64-bit] Internal error: backend/cgcod.c 1845

Status
RESOLVED
Resolution
FIXED
Severity
normal
Priority
P2
Component
dmd
Product
D
Version
D2
Platform
x86_64
OS
Windows
Creation time
2011-02-08T16:55:00Z
Last change time
2011-02-09T19:26:12Z
Assigned to
nobody
Creator
dsimcha

Comments

Comment #0 by dsimcha — 2011-02-08T16:55:28Z
This is another insanely hard to reproduce bug. The following code produces a "Internal error: backend/cgcod.c 1845" only when compiled with -O -inline -release -unittest -m64. I reduced it as far as I could. All of the seemingly unnecessary stuff is actually necessary for reproducing this bug. Also, when I copy/paste the implementation of Map into the same module as the code below, it seems to prevent the bug from being reproduced. import std.algorithm; void cleanUp() {} void doStuff(T)(T data) { scope(exit) cleanUp(); // Taking this out gets rid of the bug. size_t N = 0; foreach(i, rng; data) { // Taking this loop out gets rid of the bug. auto rngLen = rng.length; N += rngLen; } int[] dataArray; size_t pos = 0; foreach(rng; data) { // This loop is necessary. foreach(elem; rng) { dataArray[pos] = elem; pos++; } } double rBar = 0.5 * (N + 1); // Even this line is necessary. } void main() { // Only happens on instantiations with Map. doStuff( [map!"a"([3,1,4,1])] ); }
Comment #1 by bearophile_hugs — 2011-02-08T17:08:59Z
(In reply to comment #0) > This is another insanely hard to reproduce bug. As (I think) Don has said, back-end bugs are often harder to locate.
Comment #2 by clugdbug — 2011-02-08T23:12:53Z
This sounds quite similar to bug 5455. Both involve register allocation and a complicated and fragile code sequence.
Comment #3 by bugzilla — 2011-02-09T17:56:20Z