Re: Struct delegate access corruption

2021-02-18 Thread tsbockman via Digitalmars-d-learn
On Thursday, 18 February 2021 at 08:29:48 UTC, kinke wrote: Nope, Paul is right, the copy ctors don't solve anything in this regard. Simplest example I could come up with: https://run.dlang.io/is/TgxyU3 I found that example very confusing, as it does not contain an explicit copy constructor,

Re: Struct delegate access corruption

2021-02-18 Thread Paul Backus via Digitalmars-d-learn
On Thursday, 18 February 2021 at 11:00:50 UTC, vitamin wrote: opPostMove https://github.com/dlang/DIPs/blob/master/DIPs/accepted/DIP1014.md can solve this problem but it isn't implemented; IIRC opPostMove has been abandoned for the same reason postblits were abandoned (issues with

Re: Struct delegate access corruption

2021-02-18 Thread vitamin via Digitalmars-d-learn
On Thursday, 18 February 2021 at 08:29:48 UTC, kinke wrote: On Wednesday, 17 February 2021 at 20:44:46 UTC, tsbockman wrote: On Wednesday, 17 February 2021 at 20:18:53 UTC, Paul Backus wrote: [...] That bug is about postblits, this(this), not copy constructors: this(ref typeof(this)). Copy

Re: Struct delegate access corruption

2021-02-18 Thread kinke via Digitalmars-d-learn
On Wednesday, 17 February 2021 at 20:44:46 UTC, tsbockman wrote: On Wednesday, 17 February 2021 at 20:18:53 UTC, Paul Backus wrote: On Wednesday, 17 February 2021 at 19:42:00 UTC, tsbockman wrote: A copy constructor and opAssign can be used to update pointers that are relative to :

Re: Struct delegate access corruption

2021-02-17 Thread tsbockman via Digitalmars-d-learn
On Wednesday, 17 February 2021 at 20:18:53 UTC, Paul Backus wrote: On Wednesday, 17 February 2021 at 19:42:00 UTC, tsbockman wrote: A copy constructor and opAssign can be used to update pointers that are relative to : https://dlang.org/spec/struct.html#struct-copy-constructor

Re: Struct delegate access corruption

2021-02-17 Thread Paul Backus via Digitalmars-d-learn
On Wednesday, 17 February 2021 at 19:42:00 UTC, tsbockman wrote: On Wednesday, 17 February 2021 at 17:45:01 UTC, H. S. Teoh wrote: I.e., the following is NOT a good idea: struct S { void delegate() member; this() { member =

Re: Struct delegate access corruption

2021-02-17 Thread tsbockman via Digitalmars-d-learn
On Wednesday, 17 February 2021 at 17:45:01 UTC, H. S. Teoh wrote: I.e., the following is NOT a good idea: struct S { void delegate() member; this() { member = } private void impl(); }

Re: Struct delegate access corruption

2021-02-17 Thread H. S. Teoh via Digitalmars-d-learn
On Wed, Feb 17, 2021 at 03:38:00PM +, z via Digitalmars-d-learn wrote: > So i've upgraded one of my structs to use the more flexible delegates > instead of function pointers but when the member function tries to > access the struct's members, the contents are random and the program > fails.

Re: Struct delegate access corruption

2021-02-17 Thread Steven Schveighoffer via Digitalmars-d-learn
On 2/17/21 10:38 AM, z wrote: So i've upgraded one of my structs to use the more flexible delegates instead of function pointers but when the member function tries to access the struct's members, the contents are random and the program fails. i've isolated the problem by adding writefln calls

Struct delegate access corruption

2021-02-17 Thread z via Digitalmars-d-learn
So i've upgraded one of my structs to use the more flexible delegates instead of function pointers but when the member function tries to access the struct's members, the contents are random and the program fails. i've isolated the problem by adding writefln calls before calling the delegate