Building a Rust-style static analyzer for C++ with AI

https://news.ycombinator.com/rss Hits: 9
Summary

The project is available at: https://github.com/shuaimu/rusty-cpp As someone who has spent almost 15 years doing systems research with C++, I am deeply troubled by all kinds of failures, especially segmentation faults and memory corruptions. Most of these are caused by memory issues: memory leaks, dangling pointers, use-after-free, and many others. I’ve had many cases where I have a pointer that ends with an odd number. The last one literally happened last month. It gave me so many sleepless nights. I remember a memory bug that I spent a month but still could not figure out, and I ended up wrapping every raw pointer I could find with shared_ptr. So I always wished for some mechanical way that can help me eliminate all possible memory failures. The Rust Dream (and the C++ Reality) Rust is exactly what I need, and I’m happy to see this language mature. But unfortunately, many of my existing codebases that I deeply rely on are in C++. It’s not a practical decision to just drop everything and rewrite everything from scratch in Rust. One thing I used to hope for is better interop between C++ and Rust—something similar to C++ and the D language, or Swift’s limited support of C++, where you can have seamless interop. You can write one more class and that class coexists with the existing C++ codebase. But after closely following discussions in the Rust committee, I do not think this is likely to happen soon. Bringing Rust to C++ So I was very happy when I came across another option: bring similar memory safety features, the borrow checking and all, from Rust to C++. This is actually not a dead end, because in many ways C++ is a superset of Rust’s features. The first direction I was thinking: can we utilize C++’s overly powerful macro syntax to track the borrows? Imagine if we could achieve this without having to modify the compiler. After doing research for a while, I realized somebody had already tried this approach. Engineers at Google had already tried it, and this is an...

First seen: 2026-01-05 07:22

Last seen: 2026-01-05 15:23