`-latomic` required on x86 (32-bit) for `std::atomic<double>` with `-std >= c++20`
- Dominant language
- LLVM
- Stars
- 40.5k
- Forks
- 18.7k
- PR merge metrics
- PR metrics pending
Description
I'm not entirely sure whether it's an actual bug or expected behavior however it is somewhat odd results differs depending on C++ version used for compilation:
With C++11 or C++17 it works fine:
```
$ printf '#include \nint main() { std::atomic a; a = 1; }' | clang++ -march=i686 -std=c++17 -x c++ - -o /dev/null
$
```
while with C++20 or C++23 it fails on missing symbol (appears to require `-latomic`):
```
$ printf '#include \nint main() { std::atomic a; a = 1; }' | clang++ -march=i686 -std=c++20 -x c++ - -o /dev/null
/usr/bin/ld: /tmp/--c512c3.o: in function `std::__atomic_float::store(double, std::memory_order)':
-:(.text._ZNSt14__atomic_floatIdE5storeEdSt12memory_order[_ZNSt14__atomic_floatIdE5storeEdSt12memory_order]+0x94): undefined reference to `__atomic_store'
/usr/bin/ld: -:(.text._ZNSt14__atomic_floatIdE5storeEdSt12memory_order[_ZNSt14__atomic_floatIdE5storeEdSt12memory_order]+0xc9): undefined reference to `__atomic_store'
/usr/bin/ld: -:(.text._ZNSt14__atomic_floatIdE5storeEdSt12memory_order[_ZNSt14__atomic_floatIdE5storeEdSt12memory_order]+0xfe): undefined reference to `__atomic_store'
clang++: error: linker command failed with exit code 1 (use -v to see invocation)
```
LLVM 20.1.8
x86 (32-bit)
Linux
Contributor guide
Research direction
Start by reproducing the two clang++ commands on 32-bit x86 Linux and compare the C++17 and C++20 paths for std::atomic. Trace the std::__atomic_float::store implementation and its link requirements; done means determining whether the C++20+ difference is expected and, if not, locating the compiler or library change needed to resolve the missing __atomic_store symbols.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- cpp
- Domain
- compilers
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Active
- Clarity
- Needs clarification
- Newbie friendliness
- 48/100