Fix issue 20401 - The glue shouldn't copy side effects by value where the lvalue is wanted#10577
Conversation
f7095c5 to
5c2ae5e
Compare
|
Thanks for your pull request and interest in making D better, @SSoulaimane! We are looking forward to reviewing it, and you should be hearing from a maintainer soon.
Please see CONTRIBUTING.md for more information. If you have addressed all reviews or aren't sure how to proceed, don't hesitate to ping us with a simple comment. Bugzilla references
Testing this PR locallyIf you don't have a local development environment setup, you can use Digger to test this PR: dub fetch digger
dub run digger -- build "master + dmd#10577" |
|
Please use a while loop instead of a for, otherwise looks good. |
See https://issues.dlang.org/show_bug.cgi?id=20401; a testcase will be added with dlang/dmd#10577. It's a pretty serious issue (the previously returned reference in the testcase was a dangling reference to a local memcopy of the original value in memory), hence this early fix.
5c2ae5e to
5f92bbb
Compare
|
Done. |
| !(erx.ET && type_size(erx.ET) <= 16)) | ||
| else if (elemIsLvalue(erx)) | ||
| { | ||
| /* Expensive to copy, to take a pointer to it instead |
There was a problem hiding this comment.
Not retaining this behavior for expensive-to-copy things?
There was a problem hiding this comment.
It is retained actually, structs bigger than two registers match the given definition of lvalue, i.e they are always lvalues in the backend regardless of the frontend's judgement. As far as the backend is concerned what lives in registers is an rvalue and what lives in memory is an lvalue.
5f92bbb to
4cfff1c
Compare
… the lvalue is wanted By ref semantics should be preserved when extracting side effects.
I think we're fine with master for now. |
See https://issues.dlang.org/show_bug.cgi?id=20401; a testcase will be added with dlang/dmd#10577. It's a pretty serious issue (the previously returned reference in the testcase was a dangling reference to a local memcopy of the original value in memory), hence this early fix.
|
This introduced a regression: https://issues.dlang.org/show_bug.cgi?id=20809 |
Issue 20401.