4 ms·
Oof that's a very nasty bug. Is this still relevant in Zig or is there a workaround in the language? I'm not familiar with Zig, heard some good things about it,
by gnulinux 3y ago
Oof that's a very nasty bug. Is this still relevant in Zig or is there a workaround in the language? I'm not familiar with Zig, heard some good things about it, but this looks like a showstopper.
- slimsag 3y agostill relevant today, but as someone who writes a lot of Zig code I haven't ever really encountered it in the wild. You definitely could, though, and it'd be wildly confusing. Luckily, the Zig core team has recognized it is an issue and plan to address it before 1.0 :)
- Cloudef 3y agoIt's rare to hit it, but if you do, having it happen silently is not ideal for sure.
- ForkMeOnTinder 3y agoI still think noalias-by-default is the way to fix this. https://github.com/ziglang/zig/issues/1108 https://github.com/ziglang/zig/issues/1108 You get all the benefits of Zig being able to choose the function ABI, but if the optimization would have caused a bug, you'll get an immediate panic at the function entrypoint, instead of silently corrupted data.
- MatthiasPortzel 3y agoIt’s a bit confusing when compared with other programming languages. But the Zig docs’ introduction to structs are pretty clear that they can be pass-by-value or pass-by-reference at the compiler’s discretion. If you need a copy, make a copy; if you need a reference, pass a pointer; if you don’t care, the compiler will pick one.
- avgcorrection 3y agoThe issue is still Open.