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

    <tr>
        <th>Summary</th>
        <td>
            <type_traits> std::is_trivially_copyable_v returns incorrect value in the presence of conditionally enabled constructors
        </td>
    </tr>

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

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

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

<pre>
    Repro:

```cpp
template <bool IS_CONST>
struct MyIterator
{
    constexpr MyIterator() noexcept = default;

    constexpr MyIterator(const MyIterator&) = default;
 constexpr MyIterator(MyIterator&&) noexcept = default;
    constexpr MyIterator& operator=(const MyIterator&) = default;
    constexpr MyIterator& operator=(MyIterator&&) noexcept = default;

    constexpr MyIterator(const MyIterator<false>&) noexcept
        requires IS_CONST
      : MyIterator{}
    {
    }

    // This works:
    //    template <bool IS_CONST2>
    //    constexpr MyIterator(const MyIterator<IS_CONST2>&) noexcept
    //        requires (IS_CONST and not IS_CONST2)
    //      : MyIterator{}
    //    {
 // }
};

static_assert(std::is_trivially_copy_assignable_v<MyIterator<true>>);
static_assert(std::is_trivially_move_assignable_v<MyIterator<true>>);
static_assert(std::is_trivially_copy_constructible_v<MyIterator<true>>);
static_assert(std::is_trivially_move_constructible_v<MyIterator<true>>);
static_assert(std::is_standard_layout_v<MyIterator<true>>);
static_assert(std::is_trivially_destructible_v<MyIterator<true>>);
static_assert(std::is_trivially_copyable_v<MyIterator<true>>);

static_assert(std::is_trivially_copy_assignable_v<MyIterator<false>>);
static_assert(std::is_trivially_move_assignable_v<MyIterator<false>>);
static_assert(std::is_trivially_copy_constructible_v<MyIterator<false>>);
static_assert(std::is_trivially_move_constructible_v<MyIterator<false>>);
static_assert(std::is_standard_layout_v<MyIterator<false>>);
static_assert(std::is_trivially_destructible_v<MyIterator<false>>);
static_assert(std::is_trivially_copyable_v<MyIterator<false>>); // FAILS with clang
```

The last line fails for `clang`, but is accepted by `msvc`/`gcc`.
Demo: https://godbolt.org/z/7sWPh5xYG

The alternative of using a template parameter that is constrained to be false instead of hard-coding `false` (see commented-out code) works.
</pre>
<img width="1px" height="1px" alt="" src="http://email.email.llvm.org/o/eJy0Vl1v6jgQ_TXmZVSU2CTAQx5auKwq7Ze2lVb7hBx7IN46cdae0LK__sqh5Uu3t1T9UAWW7Tk5OXOYGRmCWTeIBctuWDYfyI4q5wtp8elBeknSywcTBqXT2-IvbL1j4polc5a8fObJ7l-17W6HsG6tJAQmZqVzFm7vlrM_fr-7Z-Lb7kYg3ymC37a3hF6S889Q45vdAgBAuSYQPrX--BqfMD6FxuGTwpaAiTloXMnOEhM3x6x-gtBvn2zlEfRHWK9BnAXnb5J6nU4Orn1ei_k72V0M-m6-7xdRzFbSBowpPsU_QMU_j_91xmM4eOLomInrY8jxDRvPD-cn7tifHG3xBeMLuK9MgEfnH8LeqEenAPCqPfnen6cBl0twgvSaDAfgE0EYn7yEg2w0NI6OmPHpjwHekGx_8yDe895BwPH8LO2BJBm1lCGgJ8YngXSUUlybsCRvNkZau10q126Xu-IhS4vLDROzEzHId70dohTT_SMuA6_dBr8MvGfeZy9WIfM15D8dP5BstPR6aeXWdfS5lDV-lRhR7Pek8FMtuC9JX-LBD6FfYsKP0__8B7xpww-R_rkPPyz4hXl8qZGL69tf7-DRUAXKymZ9NvAcG_a-QrAyEFjTIKyksQFWzkOci_rQPGF8BmVHYAJIFVsCaii38UYdNqq_sGB5slZxPdzBzrGO8xZURG3fz3pia6dLZ2no_Jrxxf-ML8bh7z-r7OmfX845SUvoG0lmg-BW0AXTrEEeemArvayR0ANVsue2s4w0DWogB2V8GxsQTGyCUkeUSnp9pZyOWCxPdvrlSWxhARGUq2tsCPWV6wiU0xgbYd-ShwNdCD0VUznAIs0nggue8nRQFTpVozzPUp3KVGjJRV5OVYZpukqzqVZiYAqecJFkyYgnfDJKh1JMR2K6wvFkLHgmxmyUYC2NHVq7qaM2AxNCh0XOsywbWFmiDf2Qy3mDj9AfMs7jzOuLGHNVduvARok1gcIBhQxZLGLB2ra4jNJQYOIbvGUz8EidbwKYRjnvURFspO2ikkAVQusxYKP6vCjXaEPGNREDsC84Gva_XufDoPO2OLOBoaorh8rVjC8i3eevq9a7f1ER44v-JQPji16E7wEAAP__mwbMsA">