https://issues.dlang.org/show_bug.cgi?id=22864

Iain Buclaw <[email protected]> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |[email protected]

--- Comment #2 from Iain Buclaw <[email protected]> ---
Doesn't affect gdc-11

This is the codegen:
---
  struct S[] ret;
  struct S slot[1];
  void* mem;

  ret.length = 1;
  slot[0] = getS (); [return slot optimization]
  mem = _d_arrayliteralTX (&_D25TypeInfo_AS10issue228641S6__initZ, 1);
  __builtin_memcpy (mem, &slot, 1);
  ret.ptr = mem;
  return ret.ptr;
---

The abort occurs if the array allocation and getS() calls are reversed.
---
  struct S[] ret;
  struct S slot[1];
  void* mem;

  ret.length = 1;
  mem = _d_arrayliteralTX (&_D25TypeInfo_AS10issue228641S6__initZ, 1);
  slot[0] = getS (); [return slot optimization]
  __builtin_memcpy (mem, &slot, 1);
  ret.ptr = mem;
  return ret.ptr;
---

So with ldc (and maybe dmd), it's an issue with what order arguments are
evaluated in.  As at a high level, the lowered code would look like:
---
memcpy (_d_arrayliteralTX(), getS(), 1);
---
I guess it would be enforced LTR evaluation of C function calls.

--

Reply via email to