From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 48) id BDCF03858D39; Tue, 3 Oct 2023 18:57:40 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org BDCF03858D39 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1696359460; bh=dDVvjrwrjOMMSIZ8pjWWn7uVbuATIDZc/SEN0k2M+UM=; h=From:To:Subject:Date:From; b=R18cF1rN0ohGEuyVFhfAfB1OPXysar3g+pOW0yqxRwn6uwU/VZVL2O194jp5CdUT8 OAoamg4yy4hZbmPH/TBoXkp5WXOA/fFhPCE2uZuVlOJRCpkNITDXACGIwe/nkBIdqV v2MERYmtb5WXAxSVfJQuY11eGtuJspI9FzC4orZA= From: "knoepfel at fnal dot gov" To: gcc-bugs@gcc.gnu.org Subject: [Bug c++/111685] New: Segfault while sorting on array element address Date: Tue, 03 Oct 2023 18:57:40 +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: 13.2.0 X-Bugzilla-Keywords: X-Bugzilla-Severity: normal X-Bugzilla-Who: knoepfel at fnal dot gov 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=3D111685 Bug ID: 111685 Summary: Segfault while sorting on array element address Product: gcc Version: 13.2.0 Status: UNCONFIRMED Severity: normal Priority: P3 Component: c++ Assignee: unassigned at gcc dot gnu.org Reporter: knoepfel at fnal dot gov Target Milestone: --- The following file (`sort-bug.cpp`) results in a segmentation violation: ``` #include #include #include #include int main() { std::vector vnums{1, 5, 4}; std::array anums{1, 5, 4}; int nums[] =3D {1, 5, 4}; auto cmp =3D [](auto&& a, auto&& b) { return &a < &b; }; std::sort(vnums.begin(), vnums.end(), cmp); std::sort(anums.begin(), anums.end(), cmp); // segfault std::sort(nums, nums + 3, cmp); // segfault } ``` *Expected result*: the `vnums`, `anums`, and `nums` variables remain unalte= red after the invocation to `std::sort`. *Compiler info*: - Target: x86_64-pc-linux-gnu - Configured with: /scratch/workspace/art-build-base/v13_02_00-e28/SLF7/build/gcc/v13_1_0/src/= gcc-13.1.0/configure --enable-__cxa_atexit --enable-checking=3Drelease --enable-compressed-debug-sections=3Dall --enable-languages=3Dc,c++,fortran,go,objc,obj-c++ --enable-libstdcxx-time= =3Drt --enable-plugin --enable-stage1-checking=3Dall --enable-threads=3Dposix --prefix=3D/scratch/workspace/art-build-base/v13_02_00-e28/SLF7/build/gcc/v= 13_1_0/Linux64bit+3.10-2.17 --with-system-zlib --enable-lto --with-zstd --enable-link-serialization=3D15 - Thread model: posix - Supported LTO compression algorithms: zlib zstd - gcc version 13.1.0 (GCC)=20 *Compiler/runtime command*: `g++ sort-bug.cpp -o sort-bug -std=3Dc++20 -ped= antic -Werror -Wall; ./sort-bug`=