To POD or not to POD

Johannes Pfau nospam at example.com
Tue Feb 12 09:45:10 PST 2013


I've started debugging the unit test failures in std.datetime:

We have this Date struct:
-----
struct Date
{
    this(int a){}
    short _year  = 2;
    ubyte _month = 1;
    ubyte _day   = 1;
}
-----

It's passed to D runtime variadic functions. It's 4 bytes in total so
GCC passes this struct in registers on x86_64 and it's therefore saved
in reg_save_area.

But our va_arg implementation using TypeInfo calls TypeInfo.argTypes()
to check if the type can be passed in parameters. This check returns
false as it depends on the dmd check sym->isPOD. Therefore our va_arg
tries to load the Date instance from the overflow_arg / stack save area
instead of the register save area.

What would be the correct way to tell the gcc backend not to pass !isPOD
structs in registers? Using TREE_ADDRESSABLE?

OT: I think a simple constructor shouldn't prevent a type from being a
POD, but that should be defined by dmd /frontend.


More information about the D.gnu mailing list