[Issue 22017] New: with() on struct method that returns this destroys too early
d-bugmail at puremagic.com
d-bugmail at puremagic.com
Fri Jun 11 09:04:53 UTC 2021
https://issues.dlang.org/show_bug.cgi?id=22017
Issue ID: 22017
Summary: with() on struct method that returns this destroys too
early
Product: D
Version: D2
Hardware: x86_64
OS: Linux
Status: NEW
Severity: major
Priority: P1
Component: dmd
Assignee: nobody at puremagic.com
Reporter: default_357-line at yahoo.de
Consider the following code:
struct S {
bool destroyed;
~this() { destroyed = true; }
ref S foo() return { return this; }
}
void main() {
with (S().foo) {
assert(!destroyed);
}
}
Even if the with() expression is copied, the copied version should not see the
results of the destructor call. However, the assert fails.
--
More information about the Digitalmars-d-bugs
mailing list