public inbox for gcc-bugs@sourceware.org help / color / mirror / Atom feed
From: "redi at gcc dot gnu.org" <gcc-bugzilla@gcc.gnu.org> To: gcc-bugs@gcc.gnu.org Subject: [Bug libstdc++/108556] std::sort changes objects' member values Date: Thu, 26 Jan 2023 10:20:58 +0000 [thread overview] Message-ID: <bug-108556-4-jKx0E6hvhZ@http.gcc.gnu.org/bugzilla/> (raw) In-Reply-To: <bug-108556-4@http.gcc.gnu.org/bugzilla/> https://gcc.gnu.org/bugzilla/show_bug.cgi?id=108556 --- Comment #2 from Jonathan Wakely <redi at gcc dot gnu.org> --- Compiling with -D_GLIBCXX_DEBUG shows the problem: /home/jwakely/gcc/13/include/c++/13.0.1/bits/stl_algo.h:4892: In function: void std::sort(_RAIter, _RAIter, _Compare) [with _RAIter = gnu_debug::_Safe_iterator<gnu_cxx::normal_iterator<Item*, vector<Item, allocator<Item> > >, debug::vector<Item>, random_access_iterator_tag>; _Compare = main()::<lambda(const Item&, const Item&)>] Error: comparison doesn't meet irreflexive requirements, assert(!(a < a)). Objects involved in the operation: instance "functor" @ 0x7ffee875415f { type = main::{lambda(Item const&, Item const&)#1}; } iterator::value_type "ordered type" { type = Item; } Aborted (core dumped) Your comparison function fails to meet the requirements of a strict weak ordering, so your program has undefined behaviour. https://www.boost.org/sgi/stl/StrictWeakOrdering.html https://en.cppreference.com/w/cpp/named_req/Compare
next prev parent reply other threads:[~2023-01-26 10:20 UTC|newest] Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top 2023-01-26 10:05 [Bug libstdc++/108556] New: " gnu.iodaj at simplelogin dot com 2023-01-26 10:06 ` [Bug libstdc++/108556] " gnu.iodaj at simplelogin dot com 2023-01-26 10:20 ` redi at gcc dot gnu.org [this message] 2023-01-26 10:23 ` redi at gcc dot gnu.org 2023-07-14 19:04 ` pinskia at gcc dot gnu.org
Reply instructions: You may reply publicly to this message via plain-text email using any one of the following methods: * Save the following mbox file, import it into your mail client, and reply-to-all from there: mbox Avoid top-posting and favor interleaved quoting: https://en.wikipedia.org/wiki/Posting_style#Interleaved_style * Reply using the --to, --cc, and --in-reply-to switches of git-send-email(1): git send-email \ --in-reply-to=bug-108556-4-jKx0E6hvhZ@http.gcc.gnu.org/bugzilla/ \ --to=gcc-bugzilla@gcc.gnu.org \ --cc=gcc-bugs@gcc.gnu.org \ /path/to/YOUR_REPLY https://kernel.org/pub/software/scm/git/docs/git-send-email.html * If your mail client supports setting the In-Reply-To header via mailto: links, try the mailto: linkBe sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox; as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).