c3c icon indicating copy to clipboard operation
c3c copied to clipboard

Casting a slice address to its pointer type should not compile

Open cbuttner opened this issue 1 year ago • 1 comments

int[] array;
int* ptr = array; // This is ok
int* ptr = &array; // This should not compile (ptr has the address of the slice itself)
void* ptr = &array; // This is also weird and should probably not compile

For context: I introduced a bug by accidentally writing mem::free(&array) instead of mem::free(array) or mem::free(array.ptr).

cbuttner avatar May 15 '24 15:05 cbuttner

The void* case is a bit bad, but hard to avoid. The bug is fixed.

lerno avatar May 16 '24 12:05 lerno

Thanks.

cbuttner avatar Jun 06 '24 20:06 cbuttner