TE
科技回声
首页24小时热榜最新最佳问答展示工作
GitHubTwitter
首页

科技回声

基于 Next.js 构建的科技新闻平台,提供全球科技新闻和讨论内容。

GitHubTwitter

首页

首页最新最佳问答展示工作

资源链接

HackerNews API原版 HackerNewsNext.js

© 2025 科技回声. 版权所有。

Zig: Great Design for Great Optimizations

11 点作者 gwenzek将近 2 年前

3 条评论

lerno将近 2 年前
As a counterpoint, see this blog post on why wrapping-overflow-is-UB is bad for safety and correctness: <a href="https:&#x2F;&#x2F;c3.handmade.network&#x2F;blog&#x2F;p&#x2F;7640-on_arithmetics_and_overflow" rel="nofollow noreferrer">https:&#x2F;&#x2F;c3.handmade.network&#x2F;blog&#x2F;p&#x2F;7640-on_arithmetics_and_o...</a><p>The gist of it is that (a + b) - c becomes different from a + (b - c) and (a - c) + b.<p>While Rust picks a “fast” default that ensures non-trapping code is safe in this regard.<p>Zig on the other hand would make incorrect ordering UB which might not be immediately obviously wrong - it completely depends on the optimizations run, something which runs completely counter to notions of correctness.
prabhatexit0将近 2 年前
Nice article!
nektro将近 2 年前
Interesting!