Thread overview
[Issue 8950] postblit not called on const static array initialization
3 days ago
kinke
May 15
https://issues.dlang.org/show_bug.cgi?id=8950

Mathias LANG <pro.mathias.lang@gmail.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |pro.mathias.lang@gmail.com

--- Comment #1 from Mathias LANG <pro.mathias.lang@gmail.com> ---
The behavior of this has changed a bit.
First, qualified postblits are deprecated. Taking away the qualified, the
second test passes, but not the third one. However postblit is going to be
deprecated in the future so I doubt this'll get fixed. Leaving open until the
postblit deprecation though...

--
August 09
https://issues.dlang.org/show_bug.cgi?id=8950

Walter Bright <bugzilla@digitalmars.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |bugzilla@digitalmars.com

--- Comment #2 from Walter Bright <bugzilla@digitalmars.com> ---
Yes, this will get a WONTFIX.

--
3 days ago
https://issues.dlang.org/show_bug.cgi?id=8950

kinke <kinke@gmx.net> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |kinke@gmx.net

--- Comment #3 from kinke <kinke@gmx.net> ---
Copy ctors are currently (wrongly) ignored when copying static arrays: https://issues.dlang.org/show_bug.cgi?id=20365

This issue here is pretty bad and inconsistent - the postblit is called correctly for mutable copies and scalar non-mutable copies, only non-mutable static array copies ignore the postblit:

void main()
{
    static struct S
    {
        int x = 42;
        this(this) { x += 10; }
    }

    {
        S source;

        S mutableCopy = source;
        assert(mutableCopy.x == 52);

        const S constCopy = source;
        assert(constCopy.x == 52);
    }

    {
        S[1] source;

        auto mutableCopy = source;
        assert(mutableCopy[0].x == 52);

        const constCopy = source;
        assert(constCopy[0].x == 52); // fails

        immutable immutableCopy = source;
        assert(immutableCopy[0].x == 52); // fails
    }
}

--