Bug with references (no casting used)
maxim at maxim-fomin.ru
Sat Feb 22 10:05:35 PST 2014
On Saturday, 22 February 2014 at 17:22:51 UTC, andrea9940 wrote:
> Hi everyone,
> I was trying to get my vector struct to use extensively
> references for passing parameters and I found a subtle bug
> which make me lose a few hour.
> A sample code that shows the bug is here
> http://pastebin.com/rvcNdjAE (fails with dmd 2.064 on linux)
> I think that the code is wrong and dmd does not recognize it:
> opBinary() allocates a struct on the stack which is then
> accepted by reference in opOpAssign.
> I'd like to know if currently there are correct ways to pass
> rvalue structs by reference or if I should pass everything by
> value and hope the compiler optimizes all reduntant copies.
Looks like compiler bug.
More information about the Digitalmars-d-learn