DIP 1016--ref T accepts r-values--Formal Assessment

Nicholas Wilson iamthewilsonator at hotmail.com
Tue Jan 29 11:38:43 UTC 2019

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

More information about the Digitalmars-d-announce mailing list