[Issue 1914] New: Array initialisation from const array yeilds memory trample

d-bugmail at puremagic.com d-bugmail at puremagic.com
Wed Mar 12 15:30:24 PDT 2008


http://d.puremagic.com/issues/show_bug.cgi?id=1914

           Summary: Array initialisation from const array yeilds memory
                    trample
           Product: D
           Version: 1.028
          Platform: All
        OS/Version: Linux
            Status: NEW
          Severity: major
          Priority: P2
         Component: DMD
        AssignedTo: bugzilla at digitalmars.com
        ReportedBy: jason at spashett.com


This bug is reproducible on (at least) Linux, DMD 1.028. Windows DMD 1.026

The following code prints "0", Unless I am mistaken "a" should be initialized
with the contents of const array i. y is corrupted. With this construct,
permissible or not, the compiler should not allow this to happen.

Note that direct initialization with an array (not though an intermediate
const) does work as expected.


import std.stdio;

struct S1
{
    const float[10] i = [0,0,0,0,0,0,0,0,0,0];
    float a[10] = i;
    int y=5;
}


void main()
{
    S1    s;
    writefln(s.y);
}


-- 



More information about the Digitalmars-d-bugs mailing list