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

    <tr>
        <th>Summary</th>
        <td>
            clang compile errors in C++20 on code that compiles in other compilers
        </td>
    </tr>

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

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

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

<pre>
    I've condensed the code down to the following:

```c++
#include <vector>

template <typename T>
struct vector
{
        typedef typename std::vector<T> type;
};

class XXX;

class Y
{
        vector<XXX>::type m;

        ~Y() {}
};

class XXX
{
};

int main(int argc, const char * argv[]) {
        return 0;
}
```

In Xcode 14.3, and clang 16.0.0 and 15.0.0 on godbolt.org, when set to use C++20, this produces compile errors.  These same compilers, when set to use C++17, compile the code without errors.  Furthermore, the code compiles without errors in x86-64 gcc (trunk) on godbolt.org, and in Microsoft Visual Studio 2022 in C++20 mode.  I'm not enough of a language lawyer to make a claim about whether the code OUGHT to compile or not.

Error output from x86-64 clang (trunk) on godbolt.org:

```
In file included from <source>:1:
In file included from /opt/compiler-explorer/gcc-snapshot/lib/gcc/x86_64-linux-gnu/13.0.1/../../../../include/c++/13.0.1/vector:62:
In file included from /opt/compiler-explorer/gcc-snapshot/lib/gcc/x86_64-linux-gnu/13.0.1/../../../../include/c++/13.0.1/bits/stl_algobase.h:64:
In file included from /opt/compiler-explorer/gcc-snapshot/lib/gcc/x86_64-linux-gnu/13.0.1/../../../../include/c++/13.0.1/bits/stl_pair.h:60:
/opt/compiler-explorer/gcc-snapshot/lib/gcc/x86_64-linux-gnu/13.0.1/../../../../include/c++/13.0.1/type_traits:979:21: error: static assertion failed due to requirement 'std::__is_complete_or_unbounded(std::__type_identity<XXX>{})': template argument must be a complete class or an unbounded array
 static_assert(std::__is_complete_or_unbounded(__type_identity<_Tp>{}),
 ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/opt/compiler-explorer/gcc-snapshot/lib/gcc/x86_64-linux-gnu/13.0.1/../../../../include/c++/13.0.1/bits/stl_construct.h:188:21: note: in instantiation of template class 'std::is_destructible<XXX>' requested here
 static_assert(is_destructible<_Value_type>::value,
 ^
/opt/compiler-explorer/gcc-snapshot/lib/gcc/x86_64-linux-gnu/13.0.1/../../../../include/c++/13.0.1/bits/alloc_traits.h:947:7: note: in instantiation of function template specialization 'std::_Destroy<XXX *>' requested here
      _Destroy(__first, __last);
 ^
/opt/compiler-explorer/gcc-snapshot/lib/gcc/x86_64-linux-gnu/13.0.1/../../../../include/c++/13.0.1/bits/stl_vector.h:730:7: note: in instantiation of function template specialization 'std::_Destroy<XXX *, XXX>' requested here
        std::_Destroy(this->_M_impl._M_start, this->_M_impl._M_finish,
             ^
<source>:15:2: note: in instantiation of member function 'std::vector<XXX>::~vector' requested here
        ~Y() {}
        ^
In file included from <source>:1:
In file included from /opt/compiler-explorer/gcc-snapshot/lib/gcc/x86_64-linux-gnu/13.0.1/../../../../include/c++/13.0.1/vector:66:
/opt/compiler-explorer/gcc-snapshot/lib/gcc/x86_64-linux-gnu/13.0.1/../../../../include/c++/13.0.1/bits/stl_vector.h:367:35: error: arithmetic on a pointer to an incomplete type 'XXX'
 _M_impl._M_end_of_storage - _M_impl._M_start);
 ~~~~~~~~~~~~~~~~~~~~~~~~~ ^
/opt/compiler-explorer/gcc-snapshot/lib/gcc/x86_64-linux-gnu/13.0.1/../../../../include/c++/13.0.1/bits/stl_vector.h:728:7: note: in instantiation of member function 'std::_Vector_base<XXX, std::allocator<XXX>>::~_Vector_base' requested here
      ~vector() _GLIBCXX_NOEXCEPT
      ^
<source>:15:2: note: in instantiation of member function 'std::vector<XXX>::~vector' requested here
        ~Y() {}
        ^
<source>:9:7: note: forward declaration of 'XXX'
class XXX;
      ^
2 errors generated.
Compiler returned: 1
```

</pre>
<img width="1px" height="1px" alt="" src="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