C++26 Hazard Pointers
Hazard pointers 一直在我的 todo list 上,但是一直没有时间和机会深入研究。最近听了 Maged M. Michael 关于 hazard pointers 的分享,正好趁此机会学习下 hazard pointers,整理成一篇博客。
Hazard pointers 一直在我的 todo list 上,但是一直没有时间和机会深入研究。最近听了 Maged M. Michael 关于 hazard pointers 的分享,正好趁此机会学习下 hazard pointers,整理成一篇博客。
本文基于 llvm-project 的 release/19.x 分支版本,分析 atomics 在 Clang/LLVM 中的实现,包括 __atomic_*
builtins、C11 _Atomic
、C++11 std::atomic
等。
本文是笔者对 C++ memory model 中 atomic operations 和 memory order 的理解。
本文首先介绍了 C++ 中的 strict aliasing rule,然后深入分析编译器是如何利用 strict aliasing rule 对程序进行分析优化的,之后介绍了检测 strict aliasing violation 的动态分析工具 TypeSanitizer,最后介绍如何在编程时避免写出 strict aliasing violation 的代码。