Earlier quoted context omitted.
What are you hoping it will achieve?
The internet went down because cloudflare used a bad config... a config parsed by a rust app. One of these days the witch hunt against C will go away.
-fbounds-safety: Enforcing bounds safety for C
31–40 of 129 posts
Re: -fbounds-safety: Enforcing bounds safety for C
#32template struct Slice { T* data = nullptr; size_t size = nullptr; T& operator[](size_t index) { if (index >= size) crash_the_program(); return data[index]; } }; If you're considering this extension, just use C++ and 5 lines of standard, portable, no-weird-annotations code instead.
Or just do it in C. #define span(T) struct span_##T { size_t len; T *data; } #define span_access(T, x, i) (*({ \ span(T) *_v = (x); \ auto _i = (i); \ if (((size_t)_i) >= _v->len) abort(); \ &_v->data[_i]; \ })) https://godbolt.org/z/TvxseshGc
Re: -fbounds-safety: Enforcing bounds safety for C
#33I want an OS distro where all C code is compiled this way. OpenBSD maybe? or a fork of CheriBSD? macOS clang has supported -fbounds-safety for a while, but I"m not sure how extensively it is used.
does any distro uses clang? I thought all linux kernels were compiled using gcc.
Re: -fbounds-safety: Enforcing bounds safety for C
#34Earlier quoted context omitted.
I think UAFs are more common in mature software
Or type confusion bugs, or any other stuff that stems from complex logic having complex bugs. Boundary checking for array indexing is table stakes.
Trains shouldn't collide if the driver is correctly observing the signals, that's table stakes too. But rather than exclusively focussing on improving track to reduce derailments we also install train protection systems that automatically intervene when the driver does miss a signal. Cause that happens a lot more than a derailment. Even though "pay attention, see red signal? stop!" is conceptually super easy.
Re: -fbounds-safety: Enforcing bounds safety for C
#35I want an OS distro where all C code is compiled this way. OpenBSD maybe? or a fork of CheriBSD? macOS clang has supported -fbounds-safety for a while, but I"m not sure how extensively it is used.
>Pizlix is LFS (Linux From Scratch) 12.2 with some added components, where userland is compiled with Fil-C. This means you get the most memory safe Linux-like OS currently available.
The author, @pizlonator, is active on HN.
Re: -fbounds-safety: Enforcing bounds safety for C
#36Earlier quoted context omitted.
Or type confusion bugs, or any other stuff that stems from complex logic having complex bugs. Boundary checking for array indexing is table stakes.
table stakes, but people still mess up on it constantly. The "yeah, but that's only a problem if you're an idiot" approach to this kind of thing hasn't served us very well so it's good to see something actually being done. Trains shouldn't collide if the driver is correctly observing the signals, that's table stakes too. But rather than exclusively focussing on improving track to reduce derailments we also install tr…
This brings C one tiny step closer to the state of the art, which is commendable, but I don't believe codebases which start using this will reduce their published vulnerability count significantly. Making use of this requires effort and diligence, and I believe most codebases that can expend such effort already have a pretty good security track record.
Re: -fbounds-safety: Enforcing bounds safety for C
#37Earlier quoted context omitted.
What are you hoping it will achieve?
The internet went down because cloudflare used a bad config... a config parsed by a rust app. One of these days the witch hunt against C will go away.
Re: -fbounds-safety: Enforcing bounds safety for C
#38Earlier quoted context omitted.
The internet went down because cloudflare used a bad config... a config parsed by a rust app. One of these days the witch hunt against C will go away.
The internet didn't go down and you're mischaracterizing it as a parsing issue when the list would've exceeded memory allocation limits. They didn't hardcode a fallback config for that case. What memory safety promise did Rust fail there exactly?
Re: -fbounds-safety: Enforcing bounds safety for C
#39I want an OS distro where all C code is compiled this way. OpenBSD maybe? or a fork of CheriBSD? macOS clang has supported -fbounds-safety for a while, but I"m not sure how extensively it is used.
Maybe this: https://fil-c.org/pizlix >Pizlix is LFS (Linux From Scratch) 12.2 with some added components, where userland is compiled with Fil-C. This means you get the most memory safe Linux-like OS currently available. The author, @pizlonator, is active on HN.
Re: -fbounds-safety: Enforcing bounds safety for C
#40Has any progress been made on this? I remember seeing this proposal 3 or 4 years ago but it looks like it still hasn't been implemented. It's a shame because it seems like a useful feature. It looks like Microsoft has something similar ( https://learn.microsoft.com/en-us/cpp/code-quality/understan... ) but it would be nice to have something that worked on other platforms.
“-fbounds-safety is a language extension to enforce a strong bounds safety guarantee for C. Here is our original RFC.
We are thrilled to announce that the preview implementation of -fbounds-safety is publicly available at this fork of llvm-project. Please note that we are still actively working on incrementally open-sourcing this feature in the llvm.org/llvm-project . To date, we have landed only a small subset of our implementation, and the feature is not yet available for use there. However, the preview does contain the working feature. Here is a quick instruction on how to adopt it.”
“This fork” is https://github.com/swiftlang/llvm-project/tree/stable/202407..., Apple’s fork of LLVM. That branch is from a year ago.
I don’t know whether there’s a newer publicly available version.
There is a GSoC 2026 opportunity on upstreaming this into mainline LLVM (https://discourse.llvm.org/t/gsoc-2026-participating-in-upst...)