chrisnc wrote:

Without this change, trying to use `ATOMIC_FLAG_INIT` in a constant 
initialization context yields the following:

https://godbolt.org/z/sTvMs5a95

```
<source>:3:17: error: non-constant-expression cannot be narrowed from type 
'int' to 'atomic_bool' (aka '_Atomic(bool)') in initializer list 
[-Wc++11-narrowing]
    3 | atomic_flag x = ATOMIC_FLAG_INIT;
      |                 ^~~~~~~~~~~~~~~~
/opt/compiler-explorer/clang-trunk-20240703/lib/clang/19/include/stdatomic.h:169:28:
 note: expanded from macro 'ATOMIC_FLAG_INIT'
  169 | #define ATOMIC_FLAG_INIT { 0 }
      |                            ^
<source>:3:17: note: insert an explicit cast to silence this issue
    3 | atomic_flag x = ATOMIC_FLAG_INIT;
      |                 ^~~~~~~~~~~~~~~~
/opt/compiler-explorer/clang-trunk-20240703/lib/clang/19/include/stdatomic.h:169:28:
 note: expanded from macro 'ATOMIC_FLAG_INIT'
  169 | #define ATOMIC_FLAG_INIT { 0 }
      |                            ^
1 error generated.
Compiler returned: 1
```

https://github.com/llvm/llvm-project/pull/97534
_______________________________________________
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

Reply via email to