[clang] [libcxx] [Clang] Support atomic operations on _BitInt(N) (PR #204815)

Xavier Roche via cfe-commits cfe-commits at lists.llvm.org
Fri Jun 26 23:58:04 PDT 2026


xroche wrote:

> Otherwise an object with dirty padding can make the loop fail forever

Indeed, oh my. Reworking this a little bit, the current design is flawed

```c++
#include <stdatomic.h>
union U {
  _Atomic(_BitInt(37)) a;
  unsigned long b;
};

int main(void) {
  union U u;
  u.b = ((unsigned long)1 << 40) | 5u;   // dirty padding bit + value 5
  (void)__c11_atomic_fetch_add(&u.a, (_BitInt(37))1, memory_order_seq_cst);
  return 0;
}
```


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


More information about the cfe-commits mailing list