Bug with references (no casting used)

andrea9940 no at mail.plz
Sat Feb 22 09:22:50 PST 2014


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.


More information about the Digitalmars-d-learn mailing list