www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.bugs - [Issue 20365] New: Copy constructor not invoked on static arrays of

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

          Issue ID: 20365
           Summary: Copy constructor not invoked on static arrays of
                    structs but the postblit works
           Product: D
           Version: D2
          Hardware: All
                OS: All
            Status: NEW
          Severity: major
          Priority: P1
         Component: dmd
          Assignee: nobody puremagic.com
          Reporter: sahmi.soulaimane gmail.com

Copy constructor case: https://run.dlang.io/is/xzVWOi

```
extern(C) void puts(const char*);

struct S
{
    long[3] a;
    this(ref typeof(this)) { puts("CC"); }
}

void main()
{
    S[4] a;
    auto b = a;
}
```

Prints nothing. Expected to print "CC" four times.

Postblit case: https://run.dlang.io/is/OX4O8I

```
extern(C) void puts(const char*);

struct S
{
    long[3] a;
    this(this) { puts("PB"); }
}

void main()
{
    S[4] a;
    auto b = a;
}
```

prints "PB" four times as expected.

--
Nov 06 2019