Array literals MUST be immutable.
Denis Koroskin
2korden at gmail.com
Wed Feb 17 12:23:33 PST 2010
On Wed, 17 Feb 2010 16:58:35 +0300, dsimcha <dsimcha at yahoo.com> wrote:
> == 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.
Oh, great! Didn't know the fact, thanks!
More information about the Digitalmars-d
mailing list