From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 48) id 4E7C2385841E; Tue, 12 Mar 2024 09:05:45 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 4E7C2385841E DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1710234345; bh=VqX8sY44B8qApEdW7mW7s3i2YJJjM473pv6rCiw26hw=; h=From:To:Subject:Date:From; b=H4ElIdwzzitjpImifqF555fS5nFPbKCELIIXq8MJBHi1Ceh4ieEZIr+cM5d5mJO7a MtlVJhGFtsfmxpEb1mrYoTTm8Xjg/rSrpkcgEnfLkNlNqpvdmDkHp6dR2RlKocXYCh sTuQEFpQD53E88QmeLkuiulZyKPlmcck15SWlDbI= From: "ammiera at hotmail dot com" To: gcc-bugs@gcc.gnu.org Subject: [Bug libstdc++/114316] New: assert failure with _GLIBCXX_DEBUG and empty range of singular iterators passed std:: algorithm Date: Tue, 12 Mar 2024 09:05:43 +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: 12.2.0 X-Bugzilla-Keywords: X-Bugzilla-Severity: normal X-Bugzilla-Who: ammiera at hotmail 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 List-Id: https://gcc.gnu.org/bugzilla/show_bug.cgi?id=3D114316 Bug ID: 114316 Summary: assert failure with _GLIBCXX_DEBUG and empty range of singular iterators passed std:: algorithm Product: gcc Version: 12.2.0 Status: UNCONFIRMED Severity: normal Priority: P3 Component: libstdc++ Assignee: unassigned at gcc dot gnu.org Reporter: ammiera at hotmail dot com Target Milestone: --- Compiling the attached snippet with -D_GLIBCXX_DEBUG causes an assert to fi= re: #include #include #include int main() { std::multimap::iterator it1{}; std::multimap::iterator it2{}; (void) (it1=3D=3Dit2); // OK (void) std::find_if( it1, it2, [](const auto& el) { return el.second =3D=3D 8;}); } The runtime error: In function: constexpr _IIter std::find_if(_IIter, _IIter, _Predicate) [with _IIter = =3D=20 gnu_debug::_Safe_iterator<_Rb_tree_iterator >,=20 debug::multimap, bidirectional_iterator_tag>; _Predicate =3D= =20 main()::] Error: function requires a valid iterator range [first, last). Objects involved in the operation: iterator "first" @ 0x7ffc275311a0 { type =3D std::_Rb_tree_iterator > (mutable iterator); state =3D singular; } iterator "last" @ 0x7ffc275311d0 { type =3D std::_Rb_tree_iterator > (mutable iterator); state =3D singular; } Program terminated with signal: SIGSEGV https://godbolt.org/z/e8xa5Eoqn Tested with C++17 and C++20 mode. Initially discussed on the mailing list: https://gcc.gnu.org/pipermail/libstdc++/2024-March/058461.html=