https://gcc.gnu.org/bugzilla/show_bug.cgi?id=106376
Bug ID: 106376 Summary: The implementation of std::pointer_traits seems wrong Product: gcc Version: 13.0 Status: UNCONFIRMED Severity: normal Priority: P3 Component: libstdc++ Assignee: unassigned at gcc dot gnu.org Reporter: hewillk at gmail dot com Target Milestone: --- [pointer.traits.types]: using element_type = see below; Type: Ptr::element_type if the qualified-id Ptr::element_type is valid and denotes a type ([temp.deduct]); otherwise, T if Ptr is a class template instantiation of the form SomePointer<T, Args>, where Args is zero or more type arguments; otherwise, the specialization is *ill-formed*. So for the following, the instantiation of pointer_traits will be ill-formed, and static_assert will cause a hard error, just like libc++ and MSVC-STL do. libstdc++ specifies element_type as a meaningless type, so the static_assert still passes. Although the behavior of libstdc++ is incorrect, but I am not feel good about this static_assert hard error.. #include <iterator> struct I { using iterator_category = std::contiguous_iterator_tag; using difference_type = std::ptrdiff_t; using value_type = int; value_type& operator*() const; I& operator++(); I operator++(int); I& operator--(); I operator--(int); I& operator+=(difference_type); I& operator-=(difference_type); value_type* operator->() const; value_type& operator[](difference_type) const; friend I operator+(I, difference_type); friend I operator+(difference_type, I); friend I operator-(I, difference_type); friend difference_type operator-(I, I); auto operator<=>(const I&) const = default; }; static_assert(std::contiguous_iterator<I>); https://godbolt.org/z/sx763oMn6