[Issue 20964] poor CTFE support for backward pointer iteration

d-bugmail at puremagic.com d-bugmail at puremagic.com
Wed Sep 22 06:50:33 UTC 2021


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

--- Comment #5 from Илья Ярошенко <ilyayaroshenko at gmail.com> ---
(In reply to Илья Ярошенко from comment #4)
> (In reply to Walter Bright from comment #2)
> > It is not normal practice nor allowed by the memory model to point before
> > the beginning of a memory block. Pointing one past the end is allowed.
> > 
> > The conventional solution is to use pre-decrement for reversing, that way
> > the iteration can start with a pointer one past the end.
> 
> I am not sure what do you mean by memory model. If you mean a GC model, than
> it is fine to free the memory as soon as the point moved out of the left
> bound. At least that works well for Mir.
> 
> > I'm not understanding why the conventional solution won't work for your case.
> 
> It may work. It is just annoying to rework it each time. We have a code that
> works in runtime and we expect it works at compile time, however it doesn't.

Ah, no. It won't work because the code is generic.
Assume a double retro operation with another modifier between two retros. So,
your variant for the second retro will refer to the next after right bound of
the last first retro, which is the next left before the left bound of the
original array.

--


More information about the Digitalmars-d-bugs mailing list