Hi,
I have a really odd behavior using a u8 array.
var buffer = [_]u8 { 1, 0, 0, 1, 3, 0, 0, 0, 0, 0, 0, 0, 0x42, 0xc8, 0x3e};
Initializes a constant buffer with the values as specified,
If I however increase the array size by one using an additional element,
var buffer = [_]u8 { 1, 0, 0, 1, 3, 0, 0, 0, 0, 0, 0, 0, 0x42, 0xc8, 0x3e, 0xfa, };
initializes the array with “garbage data”. As a Zig newcomer, with reasonable low-level development experience in various other technologies, I find this behavior very interesting and troubling.
This is done on:
- A Linux 64-bit machine with the Zig 0.13.0
- The above code is done in a test.
- I will do additional tests, to see what happens to the buffer pointer, relative to other pointers etc… And see if it behaves different in an application.
Regards