[clang] [Clang] Warn when `std::atomic_thread_fence` is used with `fsanitize=thread` (PR #166542)

Dan Blackwell via cfe-commits cfe-commits at lists.llvm.org
Fri Nov 28 13:49:19 PST 2025


DanBlackwell wrote:

> > I appreciate the effort you've put into this @BStott6; are you using `atomic_thread_fence` in a way that gives false positives? Perhaps I can try to add support for them in TSan (it looks like someone has a workaround here for now: https://stackoverflow.com/a/70543751)
> 
> [This](https://github.com/llvm/llvm-project/issues/52942) issue documents false positives when using `atomic_thread_fence`. Support in TSan would be the best solution; if it's implemented, we can remove the warning.

The more I think about it, the more I see why `atomic_thread_fence` would be very tricky for TSan to work with. I do think this PR is valuable, as we can at least warn the user that they are likely to encounter false positives.

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


More information about the cfe-commits mailing list