Garbage collected pointers?

Jonathan M Davis newsgroup.d at jmdavisprog.com
Thu Mar 1 21:02:15 UTC 2018


On Thursday, March 01, 2018 15:53:08 Steven Schveighoffer via Digitalmars-d-
learn wrote:
> On 3/1/18 3:33 PM, H. S. Teoh wrote:
> > Won't a precise GC scanning for pointers to aligned objects want to skip
> > values that can't be an aligned pointer?  Though in D's case, being
> > required to be conservative would negate this.
>
> int[] x = [1,2,3];
> void[] y = x;
> y = y[1 .. $]; // misaligned pointer.
>
> It's easy to do, and it's done all over the place (buffers anyone?).

Yeah, until recently readText could kill your program because of that, which
I found out the hard way when I had to muck around with some UTF-16 files.
It's an easy mistake to make.

- Jonathan M Davis



More information about the Digitalmars-d-learn mailing list