From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 48) id BE2503858D28; Thu, 26 Jan 2023 10:05:13 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org BE2503858D28 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1674727513; bh=8PuI/bh7ds3eb7YuUCQDJ31EhEaA+Dh1nts5T8Ocdwc=; h=From:To:Subject:Date:From; b=fyGXgg1BbFbXXzFNYZ2gIXH45DqxSA2dKkOrxdKyXDMp8bf5iuSYTM1tF0P5mEtU9 XAM2/1/xtugIK0/qHOhAZq8bcRzoWSL22sapo9c7zZKQLioy/Gn3RxDeJb/UmCjc3F CDTaJqdtKkVhULMye+JD1qz0vUUdLKc2cNVIkEFw= From: "gnu.iodaj at simplelogin dot com" To: gcc-bugs@gcc.gnu.org Subject: [Bug libstdc++/108556] New: std::sort changes objects' member values Date: Thu, 26 Jan 2023 10:05:13 +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: 11.3.0 X-Bugzilla-Keywords: X-Bugzilla-Severity: normal X-Bugzilla-Who: gnu.iodaj at simplelogin 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=3D108556 Bug ID: 108556 Summary: std::sort changes objects' member values Product: gcc Version: 11.3.0 Status: UNCONFIRMED Severity: normal Priority: P3 Component: libstdc++ Assignee: unassigned at gcc dot gnu.org Reporter: gnu.iodaj at simplelogin dot com Target Milestone: --- When working on a project, I tried using std::sort to sort a vector of obje= cts, and it resulted in a crash. After looking closer, valgrind reports lots of invalid writes and the data is effectively modified during the sort. This issue doesn't happen with stable_sort nor with small enough vectors. The g++ versions tested are 11.3.0 and 12.1.0. The system is a Dell Precision 5570 running Linux Mint 21. g++ command is g++ -Wall -Wextra sort-bug.cpp (file in attachment) The compiler output is none (no warnings, no errors, no line displayed) Please find the attached file that serves as a minimal working example of t= his bug. Thank you.=