Thread overview | ||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
June 21, 2020 [Issue 20964] poor CTFE support for backward pointer (iterator) iteration | ||||
---|---|---|---|---|
| ||||
https://issues.dlang.org/show_bug.cgi?id=20964 Илья Ярошенко <ilyayaroshenko@gmail.com> changed: What |Removed |Added ---------------------------------------------------------------------------- Keywords| |CTFE, rejects-valid -- |
June 21, 2020 [Issue 20964] poor CTFE support for backward pointer iteration | ||||
---|---|---|---|---|
| ||||
https://issues.dlang.org/show_bug.cgi?id=20964 Илья Ярошенко <ilyayaroshenko@gmail.com> changed: What |Removed |Added ---------------------------------------------------------------------------- Summary|poor CTFE support for |poor CTFE support for |backward pointer (iterator) |backward pointer iteration |iteration | -- |
September 22, 2021 [Issue 20964] poor CTFE support for backward pointer iteration | ||||
---|---|---|---|---|
| ||||
https://issues.dlang.org/show_bug.cgi?id=20964 Dlang Bot <dlang-bot@dlang.rocks> changed: What |Removed |Added ---------------------------------------------------------------------------- Keywords| |pull --- Comment #1 from Dlang Bot <dlang-bot@dlang.rocks> --- @9il created dlang/dmd pull request #13094 "Fix Issue 20964" fixing this issue: - Fix Issue 20964 https://github.com/dlang/dmd/pull/13094 -- |
September 22, 2021 [Issue 20964] poor CTFE support for backward pointer iteration | ||||
---|---|---|---|---|
| ||||
https://issues.dlang.org/show_bug.cgi?id=20964 Walter Bright <bugzilla@digitalmars.com> changed: What |Removed |Added ---------------------------------------------------------------------------- CC| |bugzilla@digitalmars.com --- Comment #2 from Walter Bright <bugzilla@digitalmars.com> --- 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'm not understanding why the conventional solution won't work for your case. -- |
September 22, 2021 [Issue 20964] poor CTFE support for backward pointer iteration | ||||
---|---|---|---|---|
| ||||
https://issues.dlang.org/show_bug.cgi?id=20964 --- Comment #3 from Walter Bright <bugzilla@digitalmars.com> --- To elaborate, decrementing past the beginning could lead to a wraparound, which is why this restriction is in the memory model. -- |
September 22, 2021 [Issue 20964] poor CTFE support for backward pointer iteration | ||||
---|---|---|---|---|
| ||||
https://issues.dlang.org/show_bug.cgi?id=20964 --- Comment #4 from Илья Ярошенко <ilyayaroshenko@gmail.com> --- (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. -- |
September 22, 2021 [Issue 20964] poor CTFE support for backward pointer iteration | ||||
---|---|---|---|---|
| ||||
https://issues.dlang.org/show_bug.cgi?id=20964 --- Comment #5 from Илья Ярошенко <ilyayaroshenko@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. -- |
September 22, 2021 [Issue 20964] poor CTFE support for backward pointer iteration | ||||
---|---|---|---|---|
| ||||
https://issues.dlang.org/show_bug.cgi?id=20964 Stefan Koch <uplink.coder@gmail.com> changed: What |Removed |Added ---------------------------------------------------------------------------- CC| |uplink.coder@gmail.com --- Comment #6 from Stefan Koch <uplink.coder@gmail.com> --- To make this code example clearer: this compiles without complaints in non-@safe code and works. void main() { uint[3] arr = [1,2,3]; assert(foo(arr) == arr[0]); } uint foo(uint[3] m) { auto p = &m[0]; // pointing the first element p += 8; // pointing to an invalid address &m[9] p -= 11; // pointer to an invalid address &[m-2] p++; // after this statement pointing the valid address &m[-1] again return *++p; // *p should yield m[0]; } Because at ctfe we can actually check that the final position of the pointer the point of using it to access memory is in the range of the original memory block; I have no issues with allowing this. -- |
September 22, 2021 [Issue 20964] poor CTFE support for backward pointer iteration | ||||
---|---|---|---|---|
| ||||
https://issues.dlang.org/show_bug.cgi?id=20964 --- Comment #7 from Dlang Bot <dlang-bot@dlang.rocks> --- @9il created dlang/dmd pull request #13096 "Fix Issue 20964" fixing this issue: - Fix Issue 20964 https://github.com/dlang/dmd/pull/13096 -- |
December 13 [Issue 20964] poor CTFE support for backward pointer iteration | ||||
---|---|---|---|---|
| ||||
https://issues.dlang.org/show_bug.cgi?id=20964 --- Comment #8 from dlangBugzillaToGithub <robert.schadek@posteo.de> --- THIS ISSUE HAS BEEN MOVED TO GITHUB https://github.com/dlang/dmd/issues/19730 DO NOT COMMENT HERE ANYMORE, NOBODY WILL SEE IT, THIS ISSUE HAS BEEN MOVED TO GITHUB -- |
Copyright © 1999-2021 by the D Language Foundation