-
-
Notifications
You must be signed in to change notification settings - Fork 594
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix issue 20401 - The glue shouldn't copy side effects by value where…
… the lvalue is wanted By ref semantics should be preserved when extracting side effects.
- Loading branch information
1 parent
bf31e41
commit 5f92bbb
Showing
2 changed files
with
42 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
// https://issues.dlang.org/show_bug.cgi?id=20401 | ||
|
||
void main() | ||
{ | ||
int i; | ||
assert(&passthrough(i) == &i); | ||
} | ||
|
||
ref int passthrough(return ref int i) | ||
{ | ||
return get().flag ? i : i; | ||
} | ||
|
||
S get() { return S(); } | ||
|
||
struct S | ||
{ | ||
bool flag; | ||
~this(){} | ||
} |