DIP 1016--ref T accepts r-values--Formal Assessment
Andrei Alexandrescu
SeeWebsiteForEmail at erdani.org
Tue Jan 29 11:46:15 UTC 2019
On 1/29/19 6:38 AM, Nicholas Wilson wrote:
> On Tuesday, 29 January 2019 at 08:35:11 UTC, Manu wrote:
>> 4. "Under DIP 1016, a call with any T[] will silently "succeed" by
>> converting the slice to void[]" <-- Do you mean "... with any T[]
>> rvalue ..."? What would be the aim of that call? Can you suggest a
>> particularly sinister construction?
>
> I _think_ what is meant is:
>
> void[] allocate(size_t size);
> bool reallocate(ref void[] b, size_t s);
> void deallocate(ref void[]);
>
> T[] arr = allocate(42);
> arr.reallocate(8192); // reallocates a temporary as T[] is cast to void
> arr.deallocate(); // double free
Affirmative. (Just wrote about the same in another post). Thanks very much.
Andrei
More information about the Digitalmars-d-announce
mailing list