digitalmars.D.bugs - [Issue 23164] New: [REG 2.097] Infinite loop on assertion failure +
- d-bugmail puremagic.com (62/62) Jun 06 2022 https://issues.dlang.org/show_bug.cgi?id=23164
https://issues.dlang.org/show_bug.cgi?id=23164 Issue ID: 23164 Summary: [REG 2.097] Infinite loop on assertion failure + DMD moves struct with copy constructor Product: D Version: D2 Hardware: x86_64 OS: Linux Status: NEW Severity: regression Priority: P1 Component: dmd Assignee: nobody puremagic.com Reporter: pro.mathias.lang gmail.com The following code shows 2 assertions failures in v2.096.1, an infinite loop on v2.097.0: ``` struct std_string { std_string* ptr; ulong[3] data; this (ulong data) { this.data[] = data; this.ptr = &this; } this(const scope ref std_string from) { assert(&from is from.ptr); assert(this.ptr is null); this.ptr = &this; this.data = from.data; } ~this () { assert(this.ptr is &this); } alias opAssign = assign; ref std_string assign () (const auto ref std_string rhs) { return this.assign2(rhs); } ref std_string assign2 (const ref std_string rhs) return { assert(rhs.ptr is &rhs); assert(this.ptr is null || this.ptr is &this); this.data = rhs.data; return this; } } void main () { std_string tmp = 42; assert(tmp.ptr is &tmp); tmp = std_string(42); assert(tmp.ptr is &tmp); } ``` The original test was to see whether or not DMD would move a struct with a copy constructor. The above code compiles and runs fine with LDC & GDC, but asserts with DMD. --
Jun 06 2022