From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 48) id 365E13858D32; Mon, 29 Jan 2024 17:31:08 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 365E13858D32 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1706549468; bh=n75z/8q184izyl5iX/Tr5aPZ1dZ8FSnobYETJEjlDmo=; h=From:To:Subject:Date:From; b=qLlWsWWE6i94Tsb4y901HI30cuchbS/3ccpt1kLKuY8eLtC4z0V7kGqBUcv040ODu er/spNMshvqUgtVESslfZGg3mGWdxgC3HfSEJgjRKY5d49OGsb1WmwpsV+vqbRdmJY rqcLXOiX6K87huJBPvPTvQ3nUsGTtiim04t5anAY= From: "ostash at ostash dot kiev.ua" To: gcc-bugs@gcc.gnu.org Subject: [Bug c++/113662] New: [13/14 Regression] Wrong code for std::sort with fancy pointer Date: Mon, 29 Jan 2024 17:31:07 +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.1.0 X-Bugzilla-Keywords: X-Bugzilla-Severity: normal X-Bugzilla-Who: ostash at ostash dot kiev.ua 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=3D113662 Bug ID: 113662 Summary: [13/14 Regression] Wrong code for std::sort with fancy pointer Product: gcc Version: 13.1.0 Status: UNCONFIRMED Severity: normal Priority: P3 Component: c++ Assignee: unassigned at gcc dot gnu.org Reporter: ostash at ostash dot kiev.ua Target Milestone: --- Hello, For the following snippet compiled with "-O3 -std=3Dc++20" --- #include #include #include #include struct Foo { public: uint32_t m1;=20 uint32_t m2; uint8_t m3; }; bool operator<(const Foo& lhs, const Foo& rhs) { return lhs.m1 < rhs.m1; } template class MyAllocator=20 { public: using value_type =3D T; using pointer =3D boost::interprocess::offset_ptr; boost::interprocess::offset_ptr allocate( std::size_t n ) { return boost::interprocess::offset_ptr(a.allocate(n)); } void deallocate( boost::interprocess::offset_ptr p, std::size_t n ) { a.deallocate(p.get(), n); } std::allocator a; }; int main() { boost::container::vector> vec; vec.emplace_back().m1 =3D 4748; vec.emplace_back().m1 =3D 4687; vec.emplace_back().m1 =3D 4717; vec.emplace_back().m1 =3D 4779; std::cout << "before: " << vec.size() << '\n'; for (const auto& x : vec) std::cout << std::to_string(x.m1) << '\n'; std::sort(vec.begin(), vec.end()); std::cout << "after: " << vec.size() << '\n'; for (const auto& x : vec) std::cout << std::to_string(x.m1) << '\n'; } --- we receive the following output: --- before: 4 4748 4687 4717 4779 after: 4 4687 4717 4717 4779 --- I've managed to bisect this issue to the following commit: 429a7a88438cc80e7c58d9f63d44838089899b12 is the first bad commit commit 429a7a88438cc80e7c58d9f63d44838089899b12 Author: Andrew MacLeod Date: Tue Mar 28 12:16:34 2023 -0400 Add recursive GORI recompuations with a depth limit. PR tree-optimization/109154 gcc/ * gimple-range-gori.cc (gori_compute::may_recompute_p): Add depth limit. * gimple-range-gori.h (may_recompute_p): Add depth param. * params.opt (ranger-recompute-depth): New param. gcc/testsuite/ * gcc.dg/Walloca-13.c: Remove bogus warning that is now fixed. gcc/gimple-range-gori.cc | 30 ++++++++++++++++++++++-------- gcc/gimple-range-gori.h | 4 ++-- gcc/params.opt | 5 +++++ gcc/testsuite/gcc.dg/Walloca-13.c | 2 +- 4 files changed, 30 insertions(+), 11 deletions(-) I tried different versions of Boost to ensure that the problem is not coming from offset_ptr. It looks like that it is possible to reproduce issue with = "-O2 -ftree-partial-pre". Everything works fine with std::vector or std::allocator. I'd be glad to perform other tests if needed.=