|
|
Log in / Subscribe / Register

Memory-safe C code

Memory-safe C code

Posted Nov 16, 2025 6:52 UTC (Sun) by alx.manpages (subscriber, #145117)
In reply to: Memory-safe C code by excors
Parent article: Rust in Android: move fast and fix things (Google Security Blog)

> You could add the `unsafe` keyword to every function in your Rust program and then be careful to never call an "unsound" API (i.e. one that can actually trigger undefined behaviour when executed), and never do operations like pointer dereferencing that can trigger UB, and you'd be in the same situation as C code that only uses "memory safe APIs".

> C compilers don't do the proof

C compilers do more than that. At least if you use a long list of -Werror=... flags.

We need some more of those, I agree, but it does proof, to some extent. You need to opt in to those errors.

You can write C code where you know the compiler will prove you won't trigger most cases of UB.

I'm working specifically on a GCC patch with which you can write C functions where the compiler can prove you won't do any buffer overflows.


The LWN site is currently under high scraper load, so comment display has been suppressed for anonymous users. If you are a human, you may read the comments by clicking the button below:

Note: you can avoid this step in the future by logging into your LWN account.


Copyright © 2026, Eklektix, Inc.
Comments and public postings are copyrighted by their creators.
Linux is a registered trademark of Linus Torvalds