From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-lf1-x141.google.com (mail-lf1-x141.google.com [IPv6:2a00:1450:4864:20::141]) by sourceware.org (Postfix) with ESMTPS id 539CC385B835 for ; Thu, 9 Apr 2020 07:22:00 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.3.2 sourceware.org 539CC385B835 Received: by mail-lf1-x141.google.com with SMTP id s13so7114972lfb.9 for ; Thu, 09 Apr 2020 00:22:00 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc:content-transfer-encoding; bh=HrpiZnPvMO1BbQrybMM4XCvDzOLrIO5y+dUlqzFelW0=; b=twI3vW4wUtyjPsT6iYI+8h4dGzZA+uFZ5yZIYYSygTnP28UISFeMtVly28d4+d50qr XeNi2le+Z9/wOjraTz0ZVLEicpgWS2YDKM+x9uhboAqUCUGhvsflvwEGv0jnTsKV5OJV GNYZZY5vRwkh+oDUne/qBd0rqwKHv5nN98W90cue3WZOqaOKEcTmPbDitaDM+O6tjPfW NfcOL5GzSAYBKhRMsY3G/lI8ogbBWv55GEubkgthtDOeQIC2GBvMtP+zkwiDS4A3dKm7 l/CzuLyQgRU8+tDco3kQUvZ3bUM2TogRghVoRi1+p4r1miBAi23eUFHZ7H6a8pouV9kT VxHQ== X-Gm-Message-State: AGi0PuafjNKcgl0fVvUYrNOl716sorLI08mUf5Du3W/wJL6JSCX5/+Gm OO/SF1WvCrodnQzsKKdobRmZrdFpi5hd6FIbckc= X-Google-Smtp-Source: APiQypLXj3fw5QSi3rOJ7RbtpRD8Ne2VrdxlYeAA4XzgGY+cza1x49bEp86gljH7Kth8hUKrf0ADTuwl0Q+Z+lRWIUY= X-Received: by 2002:a05:6512:14a:: with SMTP id m10mr6911877lfo.152.1586416918716; Thu, 09 Apr 2020 00:21:58 -0700 (PDT) MIME-Version: 1.0 References: <20200403152609.GA35629@kam.mff.cuni.cz> <0dbc191e-66f7-9878-956d-96149f20f5bf@suse.cz> <20200408133252.GG2212@tucnak> <20d175a6-23df-43e5-7027-d11fc660abd1@suse.cz> <150a514d-f460-78de-fd53-43c3eb2f6d4c@suse.cz> In-Reply-To: <150a514d-f460-78de-fd53-43c3eb2f6d4c@suse.cz> From: Richard Biener Date: Thu, 9 Apr 2020 09:21:46 +0200 Message-ID: Subject: Re: [PATCH] Allow new/delete operator deletion only for replaceable. To: =?UTF-8?Q?Martin_Li=C5=A1ka?= Cc: Jason Merrill , Jakub Jelinek , Jonathan Wakely , Jan Hubicka , GCC Patches , Marc Glisse , Nathan Sidwell Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable X-Spam-Status: No, score=-4.2 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, FREEMAIL_FROM, RCVD_IN_DNSWL_NONE, SPF_HELO_NONE, SPF_PASS, TXREP autolearn=ham autolearn_force=no version=3.4.2 X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on server2.sourceware.org X-BeenThere: gcc-patches@gcc.gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Gcc-patches mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 09 Apr 2020 07:22:01 -0000 On Thu, Apr 9, 2020 at 9:00 AM Martin Li=C5=A1ka wrote: > > On 4/9/20 8:45 AM, Richard Biener wrote: > > On Thu, Apr 9, 2020 at 7:06 AM Martin Li=C5=A1ka wrote= : > >> > >> Hi. > >> > >> We've got one another sneaky test-case (thank you Marc ;) ): > >> > >> $ cat pr94314-array.C > >> #include > >> #include > >> > >> int count =3D 0; > >> > >> __attribute__((malloc, noinline)) void* operator new[](unsigned long s= z) { > >> ++count; > >> return ::operator new(sz); > >> } > >> > >> void operator delete[](void* ptr) noexcept { > >> --count; > >> ::operator delete(ptr); > >> } > >> > >> void operator delete[](void* ptr, std::size_t sz) noexcept { > >> --count; > >> ::operator delete(ptr, sz); > >> } > >> > >> int main() { > >> delete[] new int[1]; > >> if (count !=3D 0) > >> __builtin_abort (); > >> } > >> > >> I bet we need to include the Honza's fix for inline stacks. > >> Or it the test-case invalid? > > > > I don't see how inline stacking helps here when you consider > > > > void *foo(unsigned long sz) { return ::operator new(sz); } > > void operator delete[](void* ptr) noexcept { > > --count; > > ::operator delete(ptr); > > } > > > > thus regular functions inlining where definitely the inline > > stack depth does not need to match. > > I was considering quite strict rules: > - inline stack can contain only up to 1 replaceable operator new (or dele= te) > - no non-replaceable operators are allowed > - number of repl. operator much match. > > > > > I guess the testcase asks for us to match the exact > > operator form (in the testcase we match ::delete and ::new[]), > > for example by instead of looking at the decl flags > > simply match the assembler names (the mangled names) > > of the operator? > > What do you mean by 'decl flags'. We can't compare ASM names as one is ct= or > and the second one is dtor. It's about argument types that much match, ri= ght? Sure, we have to make a translation from delete to new ODR name and compare those. I thought of simply having an array of predefined pairs like { { "_Znam", "_ZdaPvm" }, ... } if programmatically translating the ODR name of the delete to the correspon= ding new one is too difficult. Richard. > Thanks, > Martin > > > > > Richard. > > > >> Thanks, > >> Martin >