[Issue 15842] struct is being copied when returned directly

2018-06-12 Thread d-bugmail--- via Digitalmars-d-bugs
https://issues.dlang.org/show_bug.cgi?id=15842

Steven Schveighoffer  changed:

   What|Removed |Added

 CC||schvei...@yahoo.com

--- Comment #5 from Steven Schveighoffer  ---
What is there to test? Either way is valid -- you can have the struct
constructed in one location, and then moved to the return value, or you can
have it constructed in place for the return value. There is no postblit or
dtor, so the struct is movable without any notification.

IMO, this should be resolved INVALID.

--


[Issue 15842] struct is being copied when returned directly

2018-06-12 Thread d-bugmail--- via Digitalmars-d-bugs
https://issues.dlang.org/show_bug.cgi?id=15842

--- Comment #4 from Atila Neves  ---
I'd only close the bug if there's a test in the testsuite that would fail if
the current behaviour ever changes.

--


[Issue 15842] struct is being copied when returned directly

2018-06-12 Thread d-bugmail--- via Digitalmars-d-bugs
https://issues.dlang.org/show_bug.cgi?id=15842

RazvanN  changed:

   What|Removed |Added

 Status|NEW |RESOLVED
 CC||razvan.nitu1...@gmail.com
 Resolution|--- |FIXED

--- Comment #3 from RazvanN  ---
Running both examples in the original bug report on master git HEAD results in
printing the same address. Closing as fixed.

--


[Issue 15842] struct is being copied when returned directly

2016-03-31 Thread via Digitalmars-d-bugs
https://issues.dlang.org/show_bug.cgi?id=15842

--- Comment #2 from hst...@quickfur.ath.cx ---
(Small structs may also be returned via registers alone, but I surmise that
using & on the struct will suppress this.)

--


[Issue 15842] struct is being copied when returned directly

2016-03-31 Thread via Digitalmars-d-bugs
https://issues.dlang.org/show_bug.cgi?id=15842

hst...@quickfur.ath.cx changed:

   What|Removed |Added

   Keywords|wrong-code  |
 CC||hst...@quickfur.ath.cx

--- Comment #1 from hst...@quickfur.ath.cx ---
I'm pretty sure this behaviour is according to spec.  Structs are supposed to
behave like glorified ints, meaning they are value types and may be freely
copied around and moved when passing between functions.  This is one reason
it's a bad idea to keep internal pointers to a struct, as the pointers will
become invalid once the struct is moved.  Returning a struct from a function is
generally implemented as storing in a temporary area on the stack, and moving
to the final stack variable once control returns to the caller.

--