http://gcc.gnu.org/bugzilla/show_bug.cgi?id=57354

--- Comment #4 from Tobias Burnus <burnus at gcc dot gnu.org> ---
(In reply to Paul Thomas from comment #3)
> This patch is preliminary since a temporary is produced, for each
> assignment, copied to the newly reallocated lhs and then deallocated.
> Clearly it would be more efficient to deallocate the lhs and then point the
> lhs to the temporary.

Well, if one has code such as
  a = [a, e]
(and not: "a = [e, a]" or "a = [a, e]*5") one could even do a simple realloc(),
which preserves the data when being extended.

However, one needs to be careful with finalization when using realloc() as both
the LHS and the array constructor would be finalized. (Order: evaluation of the
RHS, finalization of the LHS, assignment, finalization of the RHS [= of the
array constructor/temporaries]. – But that would often involve defined
assignment.)
Note: Finalization of the LHS and of function results + array/structure
constructors after their use is not yet implemented.

Reply via email to