[Issue 17448] Move semantics cause memory corruption and cryptic bugs

2022-05-30 Thread d-bugmail--- via Digitalmars-d-bugs
https://issues.dlang.org/show_bug.cgi?id=17448 --- Comment #52 from Steven Schveighoffer --- (In reply to Steven Schveighoffer from comment #51) > then it works as expected. In this case, the compiler is copying the S(x) > instance to the return value, and then destroying the original, though I'

[Issue 17448] Move semantics cause memory corruption and cryptic bugs

2022-05-30 Thread d-bugmail--- via Digitalmars-d-bugs
https://issues.dlang.org/show_bug.cgi?id=17448 --- Comment #51 from Steven Schveighoffer --- (In reply to Tomer Filiba (weka) from comment #48) > Steven, can we agree that the following snippet is NOT okay? > Regardless of @safe, let's leave it out of question. You are still not hooking copies

[Issue 17448] Move semantics cause memory corruption and cryptic bugs

2022-05-30 Thread d-bugmail--- via Digitalmars-d-bugs
https://issues.dlang.org/show_bug.cgi?id=17448 --- Comment #50 from Tomer Filiba (weka) --- Btw, I tried adding to S ``` @disable void opPostMove(const ref S oldLocation) nothrow {} ``` But it doesn't have any effect (problem compiles and produces the same issue). In C++, you can make types un

[Issue 17448] Move semantics cause memory corruption and cryptic bugs

2022-05-30 Thread d-bugmail--- via Digitalmars-d-bugs
https://issues.dlang.org/show_bug.cgi?id=17448 --- Comment #49 from Steven Schveighoffer --- On discord, we worked out a case where the compiler is moving a struct and not calling any opPostMove or other features (copy constructor, postblit, etc): ```d import std.stdio; struct S{ S* ptr;

[Issue 17448] Move semantics cause memory corruption and cryptic bugs

2022-05-30 Thread d-bugmail--- via Digitalmars-d-bugs
https://issues.dlang.org/show_bug.cgi?id=17448 --- Comment #48 from Tomer Filiba (weka) --- Steven, can we agree that the following snippet is NOT okay? Regardless of @safe, let's leave it out of question. As a bonus, it this does not involve any library code/special moves/self references. And

[Issue 17448] Move semantics cause memory corruption and cryptic bugs

2022-05-30 Thread d-bugmail--- via Digitalmars-d-bugs
https://issues.dlang.org/show_bug.cgi?id=17448 --- Comment #47 from Steven Schveighoffer --- I should rephrase my query. currently, if you create an appropriately written `opPostMove`, then the D library calls that when it's doing a semantic move of your type (e.g. if you use `std.algorithm.move

[Issue 17448] Move semantics cause memory corruption and cryptic bugs

2022-05-30 Thread d-bugmail--- via Digitalmars-d-bugs
https://issues.dlang.org/show_bug.cgi?id=17448 --- Comment #46 from Steven Schveighoffer --- e.g.: ```d struct S { S* addr; this(int dummy) { this.addr = &this; } this(ref const S other) { this.addr = &this; } static S create() { return S(1); } } ``` --

[Issue 17448] Move semantics cause memory corruption and cryptic bugs

2022-05-30 Thread d-bugmail--- via Digitalmars-d-bugs
https://issues.dlang.org/show_bug.cgi?id=17448 --- Comment #45 from Steven Schveighoffer --- I'm assuming you are missing some extra machinery here. You aren't expecting D to automatically update your references for you, right? You at least need a postblit/copy ctor. --

[Issue 17448] Move semantics cause memory corruption and cryptic bugs

2022-05-29 Thread d-bugmail--- via Digitalmars-d-bugs
https://issues.dlang.org/show_bug.cgi?id=17448 --- Comment #44 from Eyal --- Hi Steven, thanks for reaching out. This example still fails on newest dmd: struct S { S* addr; this(int dummy) { this.addr = &this; } static S create() { return S(1); } } unittest

[Issue 17448] Move semantics cause memory corruption and cryptic bugs

2022-05-29 Thread d-bugmail--- via Digitalmars-d-bugs
https://issues.dlang.org/show_bug.cgi?id=17448 Steven Schveighoffer changed: What|Removed |Added CC||schvei...@gmail.com --- Comment #43 f

[Issue 17448] Move semantics cause memory corruption and cryptic bugs

2021-08-17 Thread d-bugmail--- via Digitalmars-d-bugs
https://issues.dlang.org/show_bug.cgi?id=17448 RazvanN changed: What|Removed |Added Status|REOPENED|RESOLVED CC|

[Issue 17448] Move semantics cause memory corruption and cryptic bugs

2021-02-17 Thread d-bugmail--- via Digitalmars-d-bugs
https://issues.dlang.org/show_bug.cgi?id=17448 Richard Cattermole changed: What|Removed |Added CC||alphaglosi...@gmail.com --- Comment #41

[Issue 17448] Move semantics cause memory corruption and cryptic bugs

2021-02-17 Thread d-bugmail--- via Digitalmars-d-bugs
https://issues.dlang.org/show_bug.cgi?id=17448 --- Comment #40 from thomas.bock...@gmail.com --- (In reply to thomas.bockman from comment #39) > Are postblits even still broken? Also, I tested all of the examples posted to this issue. On recent compilers they all seem to either work correctly, or

[Issue 17448] Move semantics cause memory corruption and cryptic bugs

2021-02-17 Thread d-bugmail--- via Digitalmars-d-bugs
https://issues.dlang.org/show_bug.cgi?id=17448 thomas.bock...@gmail.com changed: What|Removed |Added CC||thomas.bock...@gmail.com --- Comme

[Issue 17448] Move semantics cause memory corruption and cryptic bugs

2018-10-02 Thread d-bugmail--- via Digitalmars-d-bugs
https://issues.dlang.org/show_bug.cgi?id=17448 --- Comment #38 from Walter Bright --- DIP 1014: https://github.com/dlang/DIPs/blob/38cec74a7471735559e3b8a7553f55102d289d28/DIPs/DIP1014.md --

[Issue 17448] Move semantics cause memory corruption and cryptic bugs

2018-10-02 Thread d-bugmail--- via Digitalmars-d-bugs
https://issues.dlang.org/show_bug.cgi?id=17448 --- Comment #37 from Walter Bright --- Looking at your example, I rewrote it into a nunnable form: import core.stdc.stdio; struct S { int i; this(int i) { printf("this() %d\n", i); this.i = i; } this(this) {

[Issue 17448] Move semantics cause memory corruption and cryptic bugs

2018-03-12 Thread d-bugmail--- via Digitalmars-d-bugs
https://issues.dlang.org/show_bug.cgi?id=17448 Carsten Blüggel changed: What|Removed |Added CC||chi...@posteo.net --

[Issue 17448] Move semantics cause memory corruption and cryptic bugs

2018-03-12 Thread d-bugmail--- via Digitalmars-d-bugs
https://issues.dlang.org/show_bug.cgi?id=17448 --- Comment #36 from Shachar Shemesh --- Hello Walter, I see two problems with your comment. The first is that I think you are missing the real point of this bug report. It is not about controlling movability. It is about being able to hook the obje

[Issue 17448] Move semantics cause memory corruption and cryptic bugs

2018-03-11 Thread d-bugmail--- via Digitalmars-d-bugs
https://issues.dlang.org/show_bug.cgi?id=17448 --- Comment #35 from Walter Bright --- (In reply to Shachar Shemesh from comment #33) > You cannot be notified when the object > moves, and once it does, the global linked list will get completely > corrupted. That is correct, and you are right to b

[Issue 17448] Move semantics cause memory corruption and cryptic bugs

2018-03-11 Thread d-bugmail--- via Digitalmars-d-bugs
https://issues.dlang.org/show_bug.cgi?id=17448 --- Comment #34 from Eyal --- Walter: Thanks, the RVO fixes are very useful and important - and will be part of any future solution we have! --

[Issue 17448] Move semantics cause memory corruption and cryptic bugs

2018-03-11 Thread d-bugmail--- via Digitalmars-d-bugs
https://issues.dlang.org/show_bug.cgi?id=17448 --- Comment #33 from Shachar Shemesh --- Like we said earlier, the safe implications are important, but are not the core of this bug report. The problem is that, as things stand with D, certain types of programming become impossible. For example, c

[Issue 17448] Move semantics cause memory corruption and cryptic bugs

2018-03-11 Thread d-bugmail--- via Digitalmars-d-bugs
https://issues.dlang.org/show_bug.cgi?id=17448 --- Comment #32 from Walter Bright --- I filed two bug reports based on Tomer's work: https://issues.dlang.org/show_bug.cgi?id=18575 https://issues.dlang.org/show_bug.cgi?id=18576 which have PRs: https://github.com/dlang/dmd/pull/7989

[Issue 17448] Move semantics cause memory corruption and cryptic bugs

2018-03-07 Thread d-bugmail--- via Digitalmars-d-bugs
https://issues.dlang.org/show_bug.cgi?id=17448 --- Comment #31 from Shachar Shemesh --- Here goes: (In reply to Andrei Alexandrescu from comment #30) > Indeed it seems we are not supporting registration by address with ease for > D value types. Make that: at all. I understand that there are cas

[Issue 17448] Move semantics cause memory corruption and cryptic bugs

2018-03-07 Thread d-bugmail--- via Digitalmars-d-bugs
https://issues.dlang.org/show_bug.cgi?id=17448 Walter Bright changed: What|Removed |Added See Also||https://issues.dlang.org/sh

[Issue 17448] Move semantics cause memory corruption and cryptic bugs

2018-03-07 Thread d-bugmail--- via Digitalmars-d-bugs
https://issues.dlang.org/show_bug.cgi?id=17448 Walter Bright changed: What|Removed |Added See Also||https://issues.dlang.org/sh

[Issue 17448] Move semantics cause memory corruption and cryptic bugs

2018-03-06 Thread d-bugmail--- via Digitalmars-d-bugs
https://issues.dlang.org/show_bug.cgi?id=17448 --- Comment #30 from Andrei Alexandrescu --- Indeed it seems we are not supporting registration by address with ease for D value types. There are good reasons for that; by allowing value types to be moved around we avoid a swath of complications and

[Issue 17448] Move semantics cause memory corruption and cryptic bugs

2018-03-06 Thread d-bugmail--- via Digitalmars-d-bugs
https://issues.dlang.org/show_bug.cgi?id=17448 Jonathan M Davis changed: What|Removed |Added CC||issues.dl...@jmdavisprog.co

[Issue 17448] Move semantics cause memory corruption and cryptic bugs

2018-03-06 Thread d-bugmail--- via Digitalmars-d-bugs
https://issues.dlang.org/show_bug.cgi?id=17448 --- Comment #28 from Tomer Filiba (weka) --- My point is, @safe is so constrained that it's practically unusable, so I don't consider it a viable solution for this problem. --

[Issue 17448] Move semantics cause memory corruption and cryptic bugs

2018-03-06 Thread d-bugmail--- via Digitalmars-d-bugs
https://issues.dlang.org/show_bug.cgi?id=17448 --- Comment #27 from Tomer Filiba (weka) --- (In reply to Andrei Alexandrescu from comment #25) > > So... more special cases? > > That's a straight use of scope per DIP 1000, in fact the very design intent: > scope in a function signature specifies

[Issue 17448] Move semantics cause memory corruption and cryptic bugs

2018-03-06 Thread d-bugmail--- via Digitalmars-d-bugs
https://issues.dlang.org/show_bug.cgi?id=17448 --- Comment #26 from Eyal --- What solution is there for this use-case then? We need objects to register themselves (i.e: set out-of-scope pointers to point at them) and RAII-wise have them de-register themselves. While they are registered, we need

[Issue 17448] Move semantics cause memory corruption and cryptic bugs

2018-03-06 Thread d-bugmail--- via Digitalmars-d-bugs
https://issues.dlang.org/show_bug.cgi?id=17448 --- Comment #25 from Andrei Alexandrescu --- (In reply to Tomer Filiba (weka) from comment #24) > > We should address this situation by having writeln take scope inputs. It > > does > > not escape any pointers. > > So... more special cases? That's

[Issue 17448] Move semantics cause memory corruption and cryptic bugs

2018-03-06 Thread d-bugmail--- via Digitalmars-d-bugs
https://issues.dlang.org/show_bug.cgi?id=17448 --- Comment #24 from Tomer Filiba (weka) --- > We should address this situation by having writeln take scope inputs. It does > not escape any pointers. So... more special cases? > I think immovability is a red herring. The problem is a pointer is e

[Issue 17448] Move semantics cause memory corruption and cryptic bugs

2018-03-06 Thread d-bugmail--- via Digitalmars-d-bugs
https://issues.dlang.org/show_bug.cgi?id=17448 --- Comment #23 from Andrei Alexandrescu --- (In reply to Tomer Filiba (weka) from comment #21) > Walter, the @safe-ty aspects of the issue are one thing. In real code, @safe > is hardly workable, i.e. > > void main() { > int x; > writeln(&x

[Issue 17448] Move semantics cause memory corruption and cryptic bugs

2018-03-04 Thread d-bugmail--- via Digitalmars-d-bugs
https://issues.dlang.org/show_bug.cgi?id=17448 --- Comment #22 from Tomer Filiba (weka) --- void delegate() callback; struct S { int x; @disable this(this); this(int x) { this.x = x; callback = &inc; } void inc() { x++; } } auto f() { return

[Issue 17448] Move semantics cause memory corruption and cryptic bugs

2018-03-04 Thread d-bugmail--- via Digitalmars-d-bugs
https://issues.dlang.org/show_bug.cgi?id=17448 Tomer Filiba (weka) changed: What|Removed |Added Status|RESOLVED|REOPENED Resolution|WORKSFORME

[Issue 17448] Move semantics cause memory corruption and cryptic bugs

2018-03-03 Thread d-bugmail--- via Digitalmars-d-bugs
https://issues.dlang.org/show_bug.cgi?id=17448 Walter Bright changed: What|Removed |Added Status|NEW |RESOLVED Resolution|---

[Issue 17448] Move semantics cause memory corruption and cryptic bugs

2017-06-06 Thread via Digitalmars-d-bugs
https://issues.dlang.org/show_bug.cgi?id=17448 --- Comment #19 from anonymous4 --- (In reply to Andrei Alexandrescu from comment #14) > LDC for example is very adept at > "destructuring", i.e. exploding a struct into registers and "assembling" it > back if necessary. Carrying the notion of "immov

[Issue 17448] Move semantics cause memory corruption and cryptic bugs

2017-06-02 Thread via Digitalmars-d-bugs
https://issues.dlang.org/show_bug.cgi?id=17448 --- Comment #18 from Walter Bright --- (In reply to Walter Bright from comment #17) > Another case: > > https://github.com/dlang/dmd/pull/6852 Also: https://github.com/dlang/dmd/pull/6849 https://github.com/dlang/dmd/pull/6847 The three of them e

[Issue 17448] Move semantics cause memory corruption and cryptic bugs

2017-06-02 Thread via Digitalmars-d-bugs
https://issues.dlang.org/show_bug.cgi?id=17448 --- Comment #17 from Walter Bright --- Another case: https://github.com/dlang/dmd/pull/6852 --

[Issue 17448] Move semantics cause memory corruption and cryptic bugs

2017-05-31 Thread via Digitalmars-d-bugs
https://issues.dlang.org/show_bug.cgi?id=17448 Stanislav Blinov changed: What|Removed |Added CC||stanislav.bli...@gmail.com --- Comment #1

[Issue 17448] Move semantics cause memory corruption and cryptic bugs

2017-05-31 Thread via Digitalmars-d-bugs
https://issues.dlang.org/show_bug.cgi?id=17448 --- Comment #15 from Shachar Shemesh --- (In reply to Andrei Alexandrescu from comment #14) > * On the language definition side: the proposal would need to differentiate > among (a) constructs that are guaranteed to not move; (b) operations that > m

[Issue 17448] Move semantics cause memory corruption and cryptic bugs

2017-05-31 Thread via Digitalmars-d-bugs
https://issues.dlang.org/show_bug.cgi?id=17448 --- Comment #14 from Andrei Alexandrescu --- (In reply to Eyal from comment #13) > (In reply to Andrei Alexandrescu from comment #10) > > > Indeed, the spec should clarify under what circumstances objects can be > > moved. > > Could we get compile-

[Issue 17448] Move semantics cause memory corruption and cryptic bugs

2017-05-31 Thread via Digitalmars-d-bugs
https://issues.dlang.org/show_bug.cgi?id=17448 Walter Bright changed: What|Removed |Added See Also||https://issues.dlang.org/sh

[Issue 17448] Move semantics cause memory corruption and cryptic bugs

2017-05-31 Thread via Digitalmars-d-bugs
https://issues.dlang.org/show_bug.cgi?id=17448 --- Comment #13 from Eyal --- (In reply to Andrei Alexandrescu from comment #10) > Indeed, the spec should clarify under what circumstances objects can be > moved. Could we get compile-time errors when we accidentally do something that moves a stru

[Issue 17448] Move semantics cause memory corruption and cryptic bugs

2017-05-30 Thread via Digitalmars-d-bugs
https://issues.dlang.org/show_bug.cgi?id=17448 --- Comment #12 from Walter Bright --- Interestingly, if you change: auto f() { return CallContext(18); } to: auto f() { CallContext c = CallContext(18); return c; } it will work, i.e. no moving is done. This is because the co

[Issue 17448] Move semantics cause memory corruption and cryptic bugs

2017-05-30 Thread via Digitalmars-d-bugs
https://issues.dlang.org/show_bug.cgi?id=17448 --- Comment #11 from Walter Bright --- One possibility is to not allow escaping references to 'this' in @safe constructors. --

[Issue 17448] Move semantics cause memory corruption and cryptic bugs

2017-05-30 Thread via Digitalmars-d-bugs
https://issues.dlang.org/show_bug.cgi?id=17448 --- Comment #10 from Andrei Alexandrescu --- (In reply to Shachar Shemesh from comment #9) > There are two issues here. The first is that @safe does not warn about > unsafe behavior. Affirmative. > Interesting, but unrelated to the Weka use case. >

[Issue 17448] Move semantics cause memory corruption and cryptic bugs

2017-05-30 Thread via Digitalmars-d-bugs
https://issues.dlang.org/show_bug.cgi?id=17448 --- Comment #9 from Shachar Shemesh --- There are two issues here. The first is that @safe does not warn about unsafe behavior. Interesting, but unrelated to the Weka use case. The more interesting problem here is that certain types of programming a

[Issue 17448] Move semantics cause memory corruption and cryptic bugs

2017-05-30 Thread via Digitalmars-d-bugs
https://issues.dlang.org/show_bug.cgi?id=17448 Andrei Alexandrescu changed: What|Removed |Added CC||and...@erdani.com --- Comment #8 from

[Issue 17448] Move semantics cause memory corruption and cryptic bugs

2017-05-28 Thread via Digitalmars-d-bugs
https://issues.dlang.org/show_bug.cgi?id=17448 Walter Bright changed: What|Removed |Added See Also||https://issues.dlang.org/sh

[Issue 17448] Move semantics cause memory corruption and cryptic bugs

2017-05-28 Thread via Digitalmars-d-bugs
https://issues.dlang.org/show_bug.cgi?id=17448 Walter Bright changed: What|Removed |Added Keywords||safe CC|

[Issue 17448] Move semantics cause memory corruption and cryptic bugs

2017-05-28 Thread via Digitalmars-d-bugs
https://issues.dlang.org/show_bug.cgi?id=17448 --- Comment #7 from Tomer Filiba (weka) --- it is obviously not a codegen issue, since i have a dangling pointer at hand. it's just a matter of how the much stack the compiler requires. in LDC i reproduce this by enlarging the tmp to 30 elements: du

[Issue 17448] Move semantics cause memory corruption and cryptic bugs

2017-05-28 Thread via Digitalmars-d-bugs
https://issues.dlang.org/show_bug.cgi?id=17448 --- Comment #6 from b2.t...@gmx.com --- It looks like a bad codegen and not a @safe issue. `ulong[20] tmp;` is not corrupted if i compile and run your example with LDC2. --

[Issue 17448] Move semantics cause memory corruption and cryptic bugs

2017-05-28 Thread via Digitalmars-d-bugs
https://issues.dlang.org/show_bug.cgi?id=17448 Shachar Shemesh changed: What|Removed |Added CC||shac...@weka.io --- Comment #5 from Shacha

[Issue 17448] Move semantics cause memory corruption and cryptic bugs

2017-05-28 Thread via Digitalmars-d-bugs
https://issues.dlang.org/show_bug.cgi?id=17448 Eyal changed: What|Removed |Added CC||e...@weka.io --- Comment #4 from Eyal --- @uplink: W

[Issue 17448] Move semantics cause memory corruption and cryptic bugs

2017-05-28 Thread via Digitalmars-d-bugs
https://issues.dlang.org/show_bug.cgi?id=17448 uplink.co...@googlemail.com changed: What|Removed |Added CC||uplink.co...@googlemail.com ---

[Issue 17448] Move semantics cause memory corruption and cryptic bugs

2017-05-28 Thread via Digitalmars-d-bugs
https://issues.dlang.org/show_bug.cgi?id=17448 Tomer Filiba (weka) changed: What|Removed |Added CC||to...@weka.io --

[Issue 17448] Move semantics cause memory corruption and cryptic bugs

2017-05-28 Thread via Digitalmars-d-bugs
https://issues.dlang.org/show_bug.cgi?id=17448 --- Comment #2 from Tomer Filiba (weka) --- alternatively a move-operator is required --

[Issue 17448] Move semantics cause memory corruption and cryptic bugs

2017-05-28 Thread via Digitalmars-d-bugs
https://issues.dlang.org/show_bug.cgi?id=17448 --- Comment #1 from Tomer Filiba (weka) --- I understand changing this might break backwards compatibility, but something like a `pragma(dontmove);` in the struct is a must... that way it won't have compiled, and we would pass it by ref instead of re

[Issue 17448] Move semantics cause memory corruption and cryptic bugs

2017-05-28 Thread via Digitalmars-d-bugs
https://issues.dlang.org/show_bug.cgi?id=17448 Tomer Filiba (weka) changed: What|Removed |Added Keywords||industry --