DIP 1016--ref T accepts r-values--Formal Assessment
Walter Bright
newshound2 at digitalmars.com
Wed Jan 30 06:24:22 UTC 2019
On 1/29/2019 3:45 AM, Andrei Alexandrescu wrote:
> I am talking about this:
>
> int[] a = cast(int[]) alloc.allocate(100 * int.sizeof);
> if (alloc.reallocate(a, 200 * int.sizeof)
> {
> assert(a.length == 200);
> }
Even simpler:
void func(ref void* p) {
free(p); // frees (1)
p = malloc(100); // (2)
}
int* p = cast(int*)malloc(16); // (1)
func(p); // p copied to temp for conversion to void*
free(p); // frees (1) again
// (2) is left dangling
It's a memory corruption issue, with no way to detect it.
More information about the Digitalmars-d-announce
mailing list