A Riddle: what is wrong with this code using std.array.Appender?
H. S. Teoh
hsteoh at quickfur.ath.cx
Mon Mar 25 18:39:26 UTC 2019
On Mon, Mar 25, 2019 at 06:21:12PM +0000, Meta via Digitalmars-d wrote:
> On Monday, 25 March 2019 at 17:32:13 UTC, Steven Schveighoffer wrote:
[...]
> > I have a feeling it's an aliasing thing -- like every app member in
> > every class points at the same IMPL struct.
[...]
> I find that a bit strange, since you'd think that Appender would
> initialize its payload on the first append; and it seems like it does
> if you look at the code (in Appender.ensureAddable). I'm not sure how
> it shakes out that the two Appenders end up sharing the same memory.
This is pretty bad; two Appenders sharing the same memory could
potentially be exploited to break immutable.
T
--
In a world without fences, who needs Windows and Gates? -- Christian Surchi
More information about the Digitalmars-d
mailing list