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

[email protected] changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |[email protected]
           Hardware|x86_64                      |All
                 OS|Linux                       |All

--- Comment #1 from [email protected] ---
The issue is, of course, that a default initialized Appender does not have an
associated array yet. When such a not-really-initialized Appender is copied,
the copy and the original are completely independent from each other. Writing
to one doesn't affect the other. In the formattedWrite call, buffer is being
copied, so formattedWrite writes to a location of which buffer doesn't know.

Other variants that work:
----
auto buffer = appender!string;
formattedWrite(buffer, "foo");

Appender!string buffer;
formattedWrite(&buffer, "foo");
----

As for a fix, I'm not sure what should be done here. `disable this();` for
Appender is an idea, but that would probably break quite some code.

--

Reply via email to