From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 48) id CB33A385841A; Thu, 21 Jul 2022 03:56:52 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org CB33A385841A From: "hewillk at gmail dot com" To: gcc-bugs@gcc.gnu.org Subject: [Bug libstdc++/106376] New: The implementation of std::pointer_traits seems wrong Date: Thu, 21 Jul 2022 03:56:52 +0000 X-Bugzilla-Reason: CC X-Bugzilla-Type: new X-Bugzilla-Watch-Reason: None X-Bugzilla-Product: gcc X-Bugzilla-Component: libstdc++ X-Bugzilla-Version: 13.0 X-Bugzilla-Keywords: X-Bugzilla-Severity: normal X-Bugzilla-Who: hewillk at gmail dot com X-Bugzilla-Status: UNCONFIRMED X-Bugzilla-Resolution: X-Bugzilla-Priority: P3 X-Bugzilla-Assigned-To: unassigned at gcc dot gnu.org X-Bugzilla-Target-Milestone: --- X-Bugzilla-Flags: X-Bugzilla-Changed-Fields: bug_id short_desc product version bug_status bug_severity priority component assigned_to reporter target_milestone Message-ID: Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable X-Bugzilla-URL: http://gcc.gnu.org/bugzilla/ Auto-Submitted: auto-generated MIME-Version: 1.0 X-BeenThere: gcc-bugs@gcc.gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Gcc-bugs mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 21 Jul 2022 03:56:52 -0000 https://gcc.gnu.org/bugzilla/show_bug.cgi?id=3D106376 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]:=20 using element_type =3D see below; Type: Ptr=E2=80=8B::=E2=80=8Belement_=C2=ADtype if the qualified-id Ptr=E2= =80=8B::=E2=80=8Belement_=C2=ADtype is valid and denotes a type ([temp.deduct]); otherwise, T if Ptr is a class template instantiation of the form SomePointer, 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-forme= d, 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 abo= ut this static_assert hard error.. #include struct I { using iterator_category =3D std::contiguous_iterator_tag; using difference_type =3D std::ptrdiff_t; using value_type =3D int; value_type& operator*() const; I& operator++(); I operator++(int); I& operator--(); I operator--(int); I& operator+=3D(difference_type); I& operator-=3D(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<=3D>(const I&) const =3D default; }; static_assert(std::contiguous_iterator); https://godbolt.org/z/sx763oMn6=