www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.bugs - [Issue 21368] New: copy-constructors aren't called for static arrays

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

          Issue ID: 21368
           Summary: copy-constructors aren't called for static arrays
           Product: D
           Version: D2
          Hardware: All
                OS: All
            Status: NEW
          Severity: blocker
          Priority: P1
         Component: dmd
          Assignee: nobody puremagic.com
          Reporter: ilyayaroshenko gmail.com

struct S
{
    int* data;
 safe pure nothrow  nogc:
    this(ref return scope inout typeof(this)) inout{
        pragma(inline, false);

    }
}

S[3] foo(ref S[3] r)
{
    return r;
}

/// just copies memory and don't call S.__ctor

example.S[3] example.foo(ref example.S[3]):
        mov     rax, rdi
        mov     rcx, qword ptr [rsi + 16]
        mov     qword ptr [rdi + 16], rcx
        vmovups xmm0, xmmword ptr [rsi]
        vmovups xmmword ptr [rdi], xmm0
        ret

please make fix work with -betterC
Thanks

--
Nov 07 2020