From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 48) id 98870384F88C; Fri, 25 Nov 2022 10:33:09 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 98870384F88C DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1669372389; bh=LeQjQQBExL1/aZX/HCgCpuSFp7juos1l/M7QDrXn/wQ=; h=From:To:Subject:Date:From; b=fM0yJEGCVjJvgJq6bBE039ZhrIU5zB3wqR9EF1lom+oQOF2cE5TfT1gt+b/E6nqzr 9hq2GJrYP8qcBWgIklr5jJ+hqAc4cvLPIk7L/Kn0QMRXFgijKF/fXiJYjZ4nxXBYjl 5Uf5WkEZOGYbvgg/nTUzbk3SeIMyZUiJFSXwIXwI= From: "victor.donascimento at arm dot com" To: gcc-bugs@gcc.gnu.org Subject: [Bug tree-optimization/107868] New: [10 regression] Wrong code on AArch64 at -O1 with new/delete Date: Fri, 25 Nov 2022 10:33:09 +0000 X-Bugzilla-Reason: CC X-Bugzilla-Type: new X-Bugzilla-Watch-Reason: None X-Bugzilla-Product: gcc X-Bugzilla-Component: tree-optimization X-Bugzilla-Version: 10.4.0 X-Bugzilla-Keywords: X-Bugzilla-Severity: normal X-Bugzilla-Who: victor.donascimento at arm 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=3D107868 Bug ID: 107868 Summary: [10 regression] Wrong code on AArch64 at -O1 with new/delete Product: gcc Version: 10.4.0 Status: UNCONFIRMED Severity: normal Priority: P3 Component: tree-optimization Assignee: unassigned at gcc dot gnu.org Reporter: victor.donascimento at arm dot com Target Milestone: --- The libstdc++ execution test 20_util/allocator/1.cc test fails on the head = of the gcc-10 release branch when compiled at at the -O1 optimization level. The cddce1 tree dump reports the following elimination: Eliminating unnecessary statements:=20=20=20=20=20=20=20=20=20=20=20=20=20= =20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20= =20=20=20=20=20=20=20 Deleting : _4 =3D ~check_delete.1_3;=20=20=20=20=20=20=20=20=20=20=20=20=20= =20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20= =20=20=20=20=20=20=20=20 Deleting : operator delete (_11, 256); Deleting : _2 =3D ~check_new.0_1;=20=20=20=20=20=20=20=20=20=20=20=20=20=20= =20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20= =20=20=20=20=20=20=20=20=20=20 Deleting : _11 =3D operator new (256); leading to the spurious loss of calls to both the new and delete operators. bisecting between basepoints/gcc-10 and basepoints/gcc-11 identified the following commit as introducing the error: r10-2217-g8e8e7af514344588ff3e3da25c0cb74c12dc6a0d Author: Martin Liska Date: Fri Aug 2 08:07:15 2019 +0200 Mark DECL_SET_IS_OPERATOR_DELETE for user-provided delete operators. and the following as fixing the bug: r11-3611-g0b945f959f03a6185a3130f30bfd524d01d4142c Author: Richard Biener Date: Thu Oct 1 10:44:27 2020 +0200 make use of CALL_FROM_NEW_OR_DELETE_P Is the above patch an appropriate fix for the issue or does it mask any fur= ther shortcommings in the compiler? If we're happy with the fix, should it be backported to GCC 10? Many thanks. Here is a reduced testcase: #include struct gnu { }; bool check_new =3D false; bool check_delete =3D false; void* operator new(std::size_t n) noexcept(false) { check_new =3D true; return NULL; } void operator delete(void *v) noexcept { check_delete =3D true; return; } void operator delete(void *v, std::size_t) noexcept { ::operator delete(v); } void test01() { std::allocator obj; if (!check_new) __builtin_abort(); obj.deallocate(pobj, 256); if (!check_delete) __builtin_abort(); } int main() { test01(); return 0; }=