Open Des-Nerger opened 2 weeks ago
Maybe if the bit size of element type of memcpy is zero then memcpy should be a noop?
Small repro: https://godbolt.org/z/K6f3sE9z6
well, if you think about it, is technically correct since, in the allocator interface you can see that if you try to allocate 0 bytes: it just returns the maximum address possible with backwarf alignement. i.e: u0 has an alignement of 1 and thus returns the address of std.math.maxInt(usize)
, and when the arraylist tries to allocate a new slice for the list it'll try to allocate 0*n bytes, thus 0 bytes and it will return the same value specified above.
Now yes this shouldn't be a bug and @memcpy should just be a no-op on 0 bytes types. Or change the ArrayList type to just change the 'len' field of the internal slice on 0-sized types.
Zig Version
0.14.0-dev.1765+73de620ad
Steps to Reproduce and Observed Behavior
Expected Behavior
I think slices of zero-sized types shouldn't ever be considered aliased, even if they start from the exact same address.