Summary: [64-bit] Internal error: backend/cgcod.c 1845
           Product: D
           Version: D2
          Platform: x86_64
        OS/Version: Windows
            Status: NEW
          Severity: normal
          Priority: P2
         Component: DMD

--- Comment #0 from David Simcha <> 2011-02-08 16:55:28 PST ---
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;

    double rBar = 0.5 * (N + 1);  // Even this line is necessary.

void main() {
    // Only happens on instantiations with Map.

Configure issuemail:
------- You are receiving this mail because: -------

Reply via email to