Thread overview
[Issue 8950] postblit not called on const static array initialization
May 15, 2020
Mathias LANG
Aug 09, 2020
Walter Bright
Oct 17, 2020
kinke
Mar 29, 2023
RazvanN
May 15, 2020
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, 2020
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.

--
October 17, 2020
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
    }
}

--
March 29, 2023
https://issues.dlang.org/show_bug.cgi?id=8950

RazvanN <razvan.nitu1305@gmail.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|NEW                         |RESOLVED
                 CC|                            |razvan.nitu1305@gmail.com
         Resolution|---                         |WORKSFORME

--- Comment #4 from RazvanN <razvan.nitu1305@gmail.com> ---
Issue 20365 has been fixed and kinke's code and the original provided code do not assert anymore. Closing as WORKSFORME.

--