From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 48) id 39B363835411; Mon, 17 May 2021 16:50:08 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 39B363835411 From: "barry.revzin at gmail dot com" To: gcc-bugs@gcc.gnu.org Subject: [Bug c++/100639] New: reverse_view::reference erroneously uses iterator_traits::reference instead of iter_reference_t Date: Mon, 17 May 2021 16:50:08 +0000 X-Bugzilla-Reason: CC X-Bugzilla-Type: new X-Bugzilla-Watch-Reason: None X-Bugzilla-Product: gcc X-Bugzilla-Component: c++ X-Bugzilla-Version: 10.0 X-Bugzilla-Keywords: X-Bugzilla-Severity: normal X-Bugzilla-Who: barry.revzin 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: Mon, 17 May 2021 16:50:08 -0000 https://gcc.gnu.org/bugzilla/show_bug.cgi?id=3D100639 Bug ID: 100639 Summary: reverse_view::reference erroneously uses iterator_traits::reference instead of iter_reference_t Product: gcc Version: 10.0 Status: UNCONFIRMED Severity: normal Priority: P3 Component: c++ Assignee: unassigned at gcc dot gnu.org Reporter: barry.revzin at gmail dot com Target Milestone: --- Short example (from https://stackoverflow.com/q/67573305/2069064): #include template using iota =3D std::ranges::iota_view; template using iota_iter =3D std::ranges::iterator_t>; static_assert(std::same_as< std::reverse_iterator>::reference, int64_t>); This assertion fails when compiling with -std=3Dc++20 (because the referenc= e type is 'void') but passes with -std=3Dgnu++20. The direct reason is that the difference_type of the iota_view iterator is __int128, which is considered a signed_integral with gnu++20 but not c++20. But the reason this matters is because std::reverse_iterator::reference = is defined as std::iterator_traits::reference (which checks that I satsifies cpp17-input-iterator which has the signed_integral constraint) instead of b= eing defined as std::iter_reference_t (which has no such check). With the lat= ter implementation, the assertion above would pass on either version.=20 The result is that reversing an iota_view isn't a range on -std=3Dc++20.=