Severe 2.084 regression when using staticArray on array of struct with class and bool member

Per Nordlöw per.nordlow at gmail.com
Tue Feb 12 14:06:44 UTC 2019


The following code

class C
{
     this(int i) { this.i = i; }
     int i;
}

struct S
{
     C c;
     bool b;                  // removing this prevents bug
}

void main()
{
     import std.stdio : writeln;
     import std.array : staticArray;

     auto c = new C(42);

     const S[1] s1 = [S(c)].staticArray;
     const S[1] s2 = [S(c)];

     writeln(cast(void*)s1[0].c);
     writeln(cast(void*)s2[0].c);

     assert(s1[0].c is
            s2[0].c);
}

outputs

20
7F6CDAAC0000
core.exception.AssertError at static_array_of_struct_of_class_and_boolean_regression.d(26): Assertion failure

on my Ubuntu 18.04 x86_64 machine.

When I remove the member `b` in `S` the faulty behavior goes 
away. A regression I presume.

Has anybody already filed this in Bugzilla?

The regression happens on dmd 2.084.1 and master but not in 
latest ldc beta.


More information about the Digitalmars-d mailing list