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

科技回声

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

GitHubTwitter

首页

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

资源链接

HackerNews API原版 HackerNewsNext.js

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

Show HN: Xr0 – Vanilla C Made Safe with Annotations

17 点作者 akiarie超过 1 年前
Xr0 is a new static analyser that aims to make it possible to write vanilla C and get the same safety guarantees that are available other higher-level languages.<p>We&#x27;ve been working on Xr0 for the past couple of months and are excited to share an early prototype.<p>@betz47 and I are here to answer any questions.

5 条评论

lifthrasiir超过 1 年前
I&#x27;m glad that I wasn&#x27;t the only persion pondering the similar thing (referring to the theses), but I&#x27;m not sure if the current direction can produce a small enough solution. For example I expected the following to work even with the currently restricted xlib:<p><pre><code> #include &lt;stdlib.h&gt; foo(int **pp) [ if (@pp) { .alloc *pp; } else { .undefined; } ] { *pp = malloc(4); &#x2F;&#x2F; or: int *qq = malloc(4); *pp = qq; } </code></pre> It seems that `*pp` doesn&#x27;t even work in the abstraction. (I originally tried structs, but realized that Xr0 currently doesn&#x27;t support them.) This is crucial because you can&#x27;t just do pattern matching against abstractions and axioms, there should be some sort of tactics that massage abstractions so that appropriate axioms can be used if any. Even keeping track of non-variable places (here `*qq`) is not trivial, please consider how to handle the commented code.
评论 #37547597 未加载
Alifatisk超过 1 年前
Reminds me of <a href="https:&#x2F;&#x2F;github.com&#x2F;microsoft&#x2F;checkedc">https:&#x2F;&#x2F;github.com&#x2F;microsoft&#x2F;checkedc</a>
countWSS超过 1 年前
Seems like it has potential, try to run it for files in some open source projects like curl? Pick something gnarly with lots of string allocs.
评论 #37536514 未加载
schemescape超过 1 年前
How does it compare to existing static analysis tools for C? Any unique&#x2F;new features?<p>Does code using the annotations compile as is?
评论 #37536609 未加载
DamonHD超过 1 年前
I find it implausible that this can catch all the ways that C programmers actually do mess up (as one for ~40Y).<p>I can make even languages such as Java leak memory even though it shouldn&#x27;t be possible, nominally, so just knowing that something is returning heap-allocated memory somehow doesn&#x27;t seem to help much.<p>But I have only skimmed the page, so hopefully I am wrong!