What can be done with copy constructors / post blits

Johannes Pfau nospam at example.com
Fri Mar 1 05:59:07 PST 2013


When trying to implement non-POD types for gdc some time ago I asked on
the dmd mailing list what the backend is actually supposed to do for
non-POD types. Walter answered that they should never be passed in
registers:

--------------------------
> Wouldn't it be legal to still pass non-PODs in registers when calling
> functions and only copying them back to the stack if the address is
> needed? As we pass structs by value anyway, how could this be
> problematic?
>

No, not allowed. Consider why there are copy constructors, and what
they do.
--------------------------

Now that's probably because of my weak C++ background, but what can you
do with copy constructors that would break if the compiler passed the
non-POD type in a register to a function?

Note: If I interpret this assembly properly dmd does do exactly what
I proposed and what's illegal according to Walter:

D:   https://gist.github.com/jpf91/5064703
ASM: https://gist.github.com/jpf91/5064764


More information about the Digitalmars-d-learn mailing list