Chad Smith (@cs01_software)

Chad Smith @cs01_software 2026-11-26T05:32:43.000Z

C has been getting more memory safety features in clang. You can now express buffer sizes, lifetimes, and which lock guards which data. This is a great start, but I believe C, of all languages, can get far closer to Rust-level safety than anyone realizes. 🧵

273 30 10483 17 7
Chad Smith @cs01_software 2026-11-28T17:31:41.000Z

@emilianbold > It's hard in a team even to settle on the flags to use, let alone a given custom compiler. Ha true. Technically this can be used as a static analysis tool or supplemental check. The team's existing compiler doesn't need to be changed at all since it is still 'just c'.

0 0 3 1 0
Chad Smith @cs01_software 2026-11-26T21:49:15.000Z

@w_s_gosset This thread is about compile time checks. Fil-C is genius but it's purely runtime. https://x.com/cs01_software/status/2125826372480418259

@cs01_software

Yeah Fil-C is great! I should have mentioned how this compares. Fil-C is strictly runtime checks, with a different ABI and its own libc build. This approach keeps the C ABI, and catches most things at compile time so the error doesn't result in a panic, but can be fixed before shipping.

1 0 50 0 0
ZoomerDev @RuskiZoomer 2026-11-26T14:34:55.000Z

@cs01_software Interesting, thanks for the breakdown! I know Herb Sutter has been heavily pushing for memory safety in C++ for the past few years. I think this work is highly important in the current age since they improve the languages without impacting performance.

1 0 21 1 0
Chad Smith @cs01_software 2026-11-26T14:31:10.000Z

cppfront mostly adds run-time checks via transpilation, while this project is mostly compile-time checks. cppfront wraps null dereferences and subscripts in check calls and bans pointer arithmetic. It's closer to Fil-C's approach than to this one, though it doesn't catch use-after-free. It's also a new syntax, so code has to be rewritten into Cpp2. cppfront has its own parser. This project is built into clang and uses its machinery. So it can leverage types and the control flow graph, and do the analysis at compile time on plain C. The annotations disappear for other compilers.

1 0 29 1 0
Chad Smith @cs01_software 2026-11-26T14:08:38.000Z

Thanks for checking it out! There is no question it makes the code more verbose. But it still reads as C, so if you are a C dev it doesn't look like cpp (not sure what cpp2 is?), but there are more keywords. For me personally when reading it with these annotations it makes the code clearer despite the verbosity. In some ways it's more readable because you can tell how pointers are being treated everywhere, etc. It also becomes clear just how underspecified C code is and how much it relies on convention, assumptions, and blind trust rather than explicit semantics and tool warnings. You can check out some examples here https://github.com/cs01/llvm-project/blob/safe-c/safe-c-docs/examples.md

2 0 169 1 0
Chad Smith @cs01_software 2026-11-26T05:37:57.000Z

Yeah Fil-C is great! I should have mentioned how this compares. Fil-C is strictly runtime checks, with a different ABI and its own libc build. This approach keeps the C ABI, and catches most things at compile time so the error doesn't result in a panic, but can be fixed before shipping.

7 0 247 2 1
Chad Smith @cs01_software 2026-11-26T05:32:50.000Z

So can we make C as safe as Rust? Not yet. This proof of concept doesn't cover concurrency, may be unsound, and I probably missed things. But by leveraging clang features and adding new ones, it gets much closer than standard C, maintains compatibility, and is still just C.

6 0 279 1 0