#uninitialized variables
1 messages · Page 1 of 1 (latest)
In debug mode, Zig will write 0xaa to the memory region of the undefined variable. This makes it easy to detect uninitialised memory during crashes 🙂
You can just use <some_variable> = undefined instead
hmm, when I create the executable with zig build -Drelease-safe it still uses 170 though
that's actually what I do but I want to reuse the same memory area, mem.seting the buffer to fill zeroes but if uninit char is 170 I might fill with it instead
Apologies, I meant in safe modes
yeah, if you just want to clear the buffer to sort of "mark" it for re-use undefined is probably better (don't explicitly write 0xaa/170, just use undefined - it's clearer and also makes the operation a nop in release-fast). the reason that's done is essentially that 0x00 is a really common byte all over the place and its presence doesn't tell you much, whereas 0xaa is a much less common pattern which should therefore immediately make you think "uninitialized memory" when debugging zig