Array literals MUST be immutable.

dsimcha dsimcha at yahoo.com
Wed Feb 17 05:58:35 PST 2010


== Quote from Denis Koroskin (2korden at gmail.com)'s article
> IIRC, it was discussed before and the following solution was suggested:
> T[] toArray(T)(T[] values...)
> {
>      return values.dup; // not sure why dup is needed here, but DMD2.039
> complains about escaping reference

When using this kind of variadics, an implementation is allowed to allocate the
array on the stack for performance.  Therefore, you were trying to escape
references to a stack-allocated array.



More information about the Digitalmars-d mailing list