http://d.puremagic.com/issues/show_bug.cgi?id=6758
Don <[email protected]> changed: What |Removed |Added ---------------------------------------------------------------------------- Keywords| |wrong-code CC| |[email protected] Component|druntime |DMD OS/Version|Linux |All Severity|normal |critical --- Comment #8 from Don <[email protected]> 2012-04-13 03:24:19 PDT --- > Perhaps somebody can tell me if D-style variadic functions really should be using the __va_argsave structure on x86_64 code or should that only be applicable to C-style variadic functions (as the documentation still implies at the moment). Yes, they should. The documentation is completely wrong -- that's bug 7893. Here's what's happening. In 32 bit code, the glue layer sends dynamic arrays { size_t length, void * ptr} into the backend as if they were integers, of type ulong. That's basically a hack. In 64 bit, the hack was extended: dynamic arrays are of type ucent. Also delegates are of type cent. These are the only two cases where you can create a variable of type cent or ucent. Then, they get aligned *as if they were of type of cent or ucent* -- ie, 16 bytes, whereas they should only be aligned to 8 bytes. I believe that inside structs, dynamic arrays and delegates are aligned to only 8 bytes, so we have an inconsistency. Normally, you don't see this bug because: (1) if the number of arguments is small, they get passed in registers, so the alignment is ignored. There are 6 registers available for passing integer arguments (RDI RSI RDX RCX R8 R9), so the simplest case where this happens is 5 integers + a dynamic array. This is why the problem only shows up when a large number of variadic arguments are used; (2) the other code generation also uses the cent/ucent alignment. Workaround is to special-case delegates and arrays in stdc.stdarg. But really the compiler should be fixed. -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: -------
