Thread overview
[Issue 17331] appender can't be used for initialization twice
Apr 19, 2017
Heromyth
Mar 20, 2018
Tomáš Chaloupka
Mar 20, 2018
Tomáš Chaloupka
Dec 17, 2022
Iain Buclaw
April 19, 2017
https://issues.dlang.org/show_bug.cgi?id=17331

Heromyth <bitworld@qq.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
            Summary|appender can't be use for   |appender can't be used for
                   |initialization              |initialization twice

--
March 20, 2018
https://issues.dlang.org/show_bug.cgi?id=17331

Tomáš Chaloupka <chalucha@gmail.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |chalucha@gmail.com

--- Comment #1 from Tomáš Chaloupka <chalucha@gmail.com> ---
Here is another one:

import std.stdio;
import std.array;

class Foo
{
        auto bar = appender!(int[])();
        //auto bar = Appender!(int[])(); // Works ok
}

void main()
{
        auto f1 = new Foo();
        auto f2 = new Foo();
        f1.bar ~= 1;
        f2.bar ~= 2;

        writeln(f1.bar.data);
        writeln(f2.bar.data);
}

With appender output is:
[1, 2]
[1, 2]

With Appender:
[1]
[2]

Tested on v2.078.3 and v2.079.0

--
March 20, 2018
https://issues.dlang.org/show_bug.cgi?id=17331

--- Comment #2 from Tomáš Chaloupka <chalucha@gmail.com> ---
My guess is that problem is here: https://github.com/dlang/phobos/blob/master/std/array.d#L2884

As this constructor is called when appender is used with null arr parameter. So I guess that in CTFE _data is set to the same struct pointer?

--
December 17, 2022
https://issues.dlang.org/show_bug.cgi?id=17331

Iain Buclaw <ibuclaw@gdcproject.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
           Priority|P1                          |P3

--