www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.bugs - [Issue 22124] New: Corrupted closure when compiling with

https://issues.dlang.org/show_bug.cgi?id=22124

          Issue ID: 22124
           Summary: Corrupted closure when compiling with -preview=dip1000
           Product: D
           Version: D2
          Hardware: x86_64
                OS: Linux
            Status: NEW
          Keywords: wrong-code
          Severity: critical
          Priority: P1
         Component: dmd
          Assignee: nobody puremagic.com
          Reporter: dlang-bugzilla thecybershadow.net

The following program will segfault when compiled with -preview=dip1000, but
not otherwise:

/////////////// test.d //////////////
import core.thread;

static import std.parallelism; // ???

struct Elem
{
    uint[16] pad;
}
Elem[] arr;

void main(string[] args)
{
    arr = new Elem[1];

    fun1();
}

void fun1()
{
    fun2();
}

void fun2()
{
    fun3();
}

void fun3()
{
    foreach (ref elem; arr)
        fun4(elem);
}

void fun4(ref Elem elem)
{
    auto pelem = &elem;
    auto thread = new Thread({
        assert(&elem is pelem);
    });
    thread.start();
}
/////////////////////////////////////

--
Jul 14