<table border="1" cellspacing="0" cellpadding="8">
    <tr>
        <th>Issue</th>
        <td>
            <a href=https://github.com/llvm/llvm-project/issues/104498>104498</a>
        </td>
    </tr>

    <tr>
        <th>Summary</th>
        <td>
            In C++20, clang __is_trivially_constructible(std::atomic<float>) is false
        </td>
    </tr>

    <tr>
      <th>Labels</th>
      <td>
            clang:frontend
      </td>
    </tr>

    <tr>
      <th>Assignees</th>
      <td>
      </td>
    </tr>

    <tr>
      <th>Reporter</th>
      <td>
          androm3da
      </td>
    </tr>
</table>

<pre>
    > ยง 31.8.4 Specializations for floating-point types
> The atomic floating-point specializations are standard-layout structs. They each have a trivial destructor.

clang does not believe that these atomic floats are trivially constructible but the standard language suggests they should be.  I could be wrong but I think this issue is with clang and not the librar(ies)?

```
$ cat ~/tmp/is_triv_atomic.cpp
#include <atomic>
#include <type_traits>

static_assert(__is_trivially_constructible(std::atomic<float>));
static_assert(__is_trivially_constructible(std::atomic<double>));
static_assert(__is_trivially_constructible(std::atomic<long double>));
int foo(void) {
    return 12;
}

```

```
$ clang++ -c ~/tmp/is_triv_atomic.cpp -stdlib=libc++ -std=c++20 
/usr2/bcain/tmp/is_triv_atomic.cpp:4:15: error: static assertion failed due to requirement '__is_trivially_constructible(std::atomic<float>)'
    4 | static_assert(__is_trivially_constructible(std::atomic<float>));
      |               ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/usr2/bcain/tmp/is_triv_atomic.cpp:5:15: error: static assertion failed due to requirement '__is_trivially_constructible(std::atomic<double>)'
    5 | static_assert(__is_trivially_constructible(std::atomic<double>));
      |               ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/usr2/bcain/tmp/is_triv_atomic.cpp:6:15: error: static assertion failed due to requirement '__is_trivially_constructible(std::atomic<long double>)'
    6 | static_assert(__is_trivially_constructible(std::atomic<long double>));
      |               ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
3 errors generated.
```

```
$ clang --version
clang version 18.1.8
Target: x86_64-unknown-linux-gnu
Thread model: posix
InstalledDir: /local/mnt/workspace/install/clang-latest/bin


```

Note that gcc behaves the same way as clang in this regard.

```
$ g++ -c ~/tmp/is_triv_atomic.cpp  -std=c++20
/usr2/bcain/tmp/is_triv_atomic.cpp:4:15: error: static assertion failed
    4 | static_assert(__is_trivially_constructible(std::atomic<float>));
      |               ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/usr2/bcain/tmp/is_triv_atomic.cpp:5:15: error: static assertion failed
    5 | static_assert(__is_trivially_constructible(std::atomic<double>));
      |               ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/usr2/bcain/tmp/is_triv_atomic.cpp:6:15: error: static assertion failed
    6 | static_assert(__is_trivially_constructible(std::atomic<long double>));
      |               ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
$ g++ --version
g++ (Ubuntu 11.4.0-1ubuntu1~22.04) 11.4.0
Copyright (C) 2021 Free Software Foundation, Inc.
This is free software; see the source for copying conditions.  There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.

```

</pre>
<img width="1px" height="1px" alt="" src="http://email.email.llvm.org/o/eJzsV99v2zYQ_mvol4MFiZJt-cEPjhNhBrq0SNKHPRkUeZa40qTHH3a9h_7tAyW5jbsm29q0wIAKgWLp7j7yPp4-8phzstGICzK5IpPrEQu-NXbBtLBmlws2qo04LUh-A2RFyXIGeZaUSQH3e-SSKfkn89JoB1tjYasM81I3472R2oM_7dGR9Jqkyxj_0CIwb3aSf-7oPsNiFsF5pgWzYqzYyQQPztvAvUsizAmQ8RZadkBg4K08SKZAYO9jbDIM2t25YroBYdCBNh5qVBIPCL5lHnyL7nJS_eADpDoBN7pHlbVCqEMX83FyELEDaxBcaBp03kXzCVxrghJQYwKwBj48wN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