[libcxx-commits] [libcxx] [libc++] Handle Clang function effect analysis in hardening assertions (PR #177447)

Nikolas Klauser via libcxx-commits libcxx-commits at lists.llvm.org
Fri Jan 23 07:50:25 PST 2026


philnik777 wrote:

> > What's the plan here? Do we plan to support `-Wfunction-effects` more generally? If no, why is this special? If yes, IMO this requires an RFC, since I expect it will impact quite a bit of code in the library.
> 
> I think we should try to support `-Wfunction-effects` at least minimally, yes. Otherwise, that extension is basically useless. The fundamental problem is that with hardening, we're making functions that are arguably non-blocking potentially blocking (as far as the analysis can tell, at least).
> 
> > I expect it will impact quite a bit of code in the library
> 
> That's not my expectation. The extension is supposed to work with existing code pretty much out of the box, it's just that we did something unusual with hardening (and in particular the observe mode), which is that we added calls into the C++ runtime from places that were previously simple "frontend" functions, like `std::span`. I don't expect that we'd have to change code beyond what's done in this patch, and if we do, then I agree that we should consider whether the extension is worth supporting more generally. I'm happy to write a RFC if you feel that this change mandates it, though.

Wouldn't we have to annotate at least some (if you can change the default assumptions probably all?) external functions? e.g. the `sort` instantiations are currently diagnosed, but when everything is instantiated in the headers it's not: https://godbolt.org/z/3MWqM5e6f

I think I'd like a small RFC. I don't expect it will be rejected, but I do think that we should think a bit about the impact this has.

https://github.com/llvm/llvm-project/pull/177447


More information about the libcxx-commits mailing list