https://gcc.gnu.org/bugzilla/show_bug.cgi?id=97889

--- Comment #1 from Iain Buclaw <ibuclaw at gdcproject dot org> ---
Things go wrong because there is a SAVE_EXPR on the result of the library
function call of (val ~= 7).

It ends up being compiled down to:

  save = _d_arrayappendcTX (typeid(val), &val, 1),
    *(save.ptr + save.length - 1) = 7;

Then an address of this taken for the outer array append operation, so you end
up with:

  &(*(save = _d_arrayappendcTX (typeid(val), &val, 1),
      save.ptr + save.length - 1) = 7);

As _d_arrayappendcTX is known to return the new value of `val`, which is also
passed by reference, this can be instead lowered to ignore the return value,
and create a SAVE_EXPR on `&val' instead.

  save = &val,
    _d_arrayappendcTX (typeid(val), save, 1),
    (*save).ptr + (*save).length - 1 = 7,
    *save;

Reply via email to