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 61B04385B835 for ; Thu, 9 Apr 2020 06:45:43 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.3.2 sourceware.org 61B04385B835 Received: by mail-lf1-x141.google.com with SMTP id j17so7052603lfe.7 for ; Wed, 08 Apr 2020 23:45:43 -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=WT9607WLy1tUpABzPD38jtzTMgGm3VzsLM5hhPdHWjo=; b=U2q8DjobytmN5Ge61r1Dum21Bgnm4mHu/YXdo0G9c0mPZQWtsyIgjZ1/khmula8XCc CQOYDKqpZqIR48CWEw7MFJ+aHA2xjmuOPLE1T9d8MWoIKDtUobNWa0eqpTuxjzcuWY5m 79iPWntkxIfzgnbX0WgSXmq9ZuFiEeoBEOMerA2r+fX5eEMFXK5SE9Qw8eEwwYi9a2au XCxBll4yRU8pmfq/avXwdv1A43k6ckescwQVpjB0OphoUsionKQKC9BTbbB980MDZSAc ap/l4i5rJdspV41/T2hwnTCPu7ormUOY2aN4DD2QMms5imfeNbPa/y/8+X6Fuz1Y1obK 9vfw== X-Gm-Message-State: AGi0PubZj48Rl6kBuZVDBuUtHEF4rnvQHth/bTvSfrevJwTftBZ0Kc9h EVoWUx5Isx5G002b1BHuGP17PBJdOr+ntrwRidA= X-Google-Smtp-Source: APiQypI76QY89bIKEHtwnMk10XFoTWgB+TwKexA9WqXmM1BUNpMnOy00HtYZLPytATyDaX5wJKc1nSHW/9vhc+IrUbM= X-Received: by 2002:ac2:4309:: with SMTP id l9mr6672511lfh.65.1586414742089; Wed, 08 Apr 2020 23:45:42 -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> In-Reply-To: <20d175a6-23df-43e5-7027-d11fc660abd1@suse.cz> From: Richard Biener Date: Thu, 9 Apr 2020 08:45:30 +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.3 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 06:45:44 -0000 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 sz) = { > ++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 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? Richard. > Thanks, > Martin