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

    <tr>
        <th>Summary</th>
        <td>
            std::is_trivial gives incorrect answer with requires-clause on default constructor
        </td>
    </tr>

    <tr>
      <th>Labels</th>
      <td>
            new issue
      </td>
    </tr>

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

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

<pre>
    A class without a default constructor is not trivial. But a class with default constructors that are not eligible due to `requires` clause still is considered trivial by Clang. GCC and MSVC get this correct.

```cpp
#include <type_traits>

template <class T>
struct S {
    S()
 requires(std::is_trivially_default_constructible_v<T>) = default;

 S()
    requires(!std::is_trivially_default_constructible_v<T> &&
 std::is_default_constructible_v<T>) {}

    T t;
};

struct D {
    D(int i) : i(i) {}
    int i;
};
static_assert(!std::is_trivially_default_constructible_v<D>);
static_assert(!std::is_default_constructible_v<D>);
static_assert(!std::is_trivial_v<D>);

static_assert(!std::is_trivially_default_constructible_v<S<D>>);
static_assert(!std::is_default_constructible_v<S<D>>);

static_assert(std::is_trivial_v<S<int>>);
// Not default constructible should mean not trivial but clang
// incorrectly considers this type trivial.
static_assert(!std::is_trivial_v<S<D>>);
```

Godbolt: https://godbolt.org/z/azKW5YM4h
</pre>
<img width="1px" height="1px" alt="" src="http://email.email.llvm.org/o/eJysVUFv4jwQ_TXOZVQUnJCQQw5APnr41O9C9a32hJxkNnHX2Kw9oaK_fuUkUMpSqVtVigA5M2_eexZvhHOy0Yg5my3ZrAhER62xeS20-PkUlKY-5guolHAOniW1piMQUOMP0SmCymhHtqvIWJAOtCEgKw9SqAks-8rXzltNDqgVBMJi34tKNrJUCHWHQAZYElr81UmLjiWhx-ocgiOplB_ngWSNFuvTVCiPsFJCNxO4X61A6BoeNv-voEECavsWa7GiCQsLFi7GzyQcnmq_H094JHWluhqBRSs67nFLVkhyLPrnspNwt1eC-qpB6OO5YpAIG2DpcjgBANgwPmc8Gw_O4vjcUc2iBYsW0m1HMeq4HS3bni3z7mwPLFr1g3gGLCpOxrJoeUnuahbA5TjGp5-ZCIwn_hkgLxE-wDRdsrR4wxAAHuGCd1pcaRhNLN6aWDA-l5pADgYs_I-5vJ7hK4eqW_iOBMlqK5xDS58zpBiEfRTyy4BGbjdbv0zc5gT-RRrfwbuN-p5aDyI13YDha8bX8J-hP1OmDxTXmk7VsEOhL1MKyo58rOjmDY7UY06o4zlk3BAgPgzOGffX1_WeC6cEujTl3tSl8f_qBbREe-cBe3rN8GJibMP4-oXxtXj599vs-0PcBnUe1VmUiQDzaZImfJalWRq0eYLzSogkzmJEzpNohjMUJcc0jjM-ncaBzHnIo5BPozCKo2k6SUqMSx6XSZhUWPKQxSHuhFQTpQ47PzuQznWYJ2GSpYESJSrX7xDONT5D_5Jx7leKzX3PXdk1jsWhko7cKwpJUpjfMAwaeUD3ehcgtHtGO-ySU5TdjTvB6FvrJeisyq_Mk9R25aQyO8bXnsT4dbe35gkrYnzdU3eMr3tpvwMAAP__3cg8PA">