[Issue 17454] ABI non-conformity: produces unaligned placement of struct on stack
    via Digitalmars-d-bugs 
    digitalmars-d-bugs at puremagic.com
       
    Mon May 29 23:48:27 PDT 2017
    
    
  
https://issues.dlang.org/show_bug.cgi?id=17454
--- Comment #2 from Walter Bright <bugzilla at digitalmars.com> ---
> d_fun returns a struct by value which appears by looking at the disassembly that d_fun allocates room for the result value on it's stack, and then returns a pointer to the result in RAX.
D never does that, because then d_fun() would be returning a pointer into its
own stack, which has expired and hence is a big no-no.
What does happen is d_fun()'s caller allocates S, and then passes a pointer to
S to d_fun(), and d_fun() fills it in and returns that pointer to S.
But if S fits in a register, this does not happen, as the disassembly shows.
--
    
    
More information about the Digitalmars-d-bugs
mailing list