From patchwork Thu Jan 24 19:53:07 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Paolo Carlini X-Patchwork-Id: 1030651 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (mailfrom) smtp.mailfrom=gcc.gnu.org (client-ip=209.132.180.131; helo=sourceware.org; envelope-from=gcc-patches-return-494693-incoming=patchwork.ozlabs.org@gcc.gnu.org; receiver=) Authentication-Results: ozlabs.org; dmarc=fail (p=none dis=none) header.from=oracle.com Authentication-Results: ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=gcc.gnu.org header.i=@gcc.gnu.org header.b="PPPBMgLh"; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=oracle.com header.i=@oracle.com header.b="zoaYF4TN"; dkim-atps=neutral Received: from sourceware.org (server1.sourceware.org [209.132.180.131]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 43ltBB4hK6z9sBQ for ; Fri, 25 Jan 2019 06:53:22 +1100 (AEDT) DomainKey-Signature: a=rsa-sha1; c=nofws; d=gcc.gnu.org; h=list-id :list-unsubscribe:list-archive:list-post:list-help:sender:to:cc :from:subject:message-id:date:mime-version:content-type; q=dns; s=default; b=PXXELlY2P1MtM2/TWbRdhzqb6qCU9Pnv7y+NVtBdKFh5Q5AAYU 7eWX28S7BCKmMq+G/7muRBzbIS22OvK1LvtYnTpwhDv8FbCIIzJ7PbThR/VxWBQX e1rzHV38PAz0MMXpAgG4vu1rP2+pe1a+8oUrFOWhLCZYmxCw++S0Sv2HU= DKIM-Signature: v=1; a=rsa-sha1; c=relaxed; d=gcc.gnu.org; h=list-id :list-unsubscribe:list-archive:list-post:list-help:sender:to:cc :from:subject:message-id:date:mime-version:content-type; s= default; bh=os+9NbSQ22Mp0FbpGh5FFPRFz3c=; b=PPPBMgLhZ0Rue1XitwJB koTDulUVIa46+Djp1ZxjfxTqNIBNx6cJcS/ObL7f2lU8+xW9yzkpEYnKKHepqhKz swUaLyGGqOLqkDSOVPwd2CQI5lAwX0KEkMRl5mDtbpIi8kxqCPIjwOJpIyGc1HCT jqWJrasDD80qGbj6irJd/rU= Received: (qmail 120229 invoked by alias); 24 Jan 2019 19:53:15 -0000 Mailing-List: contact gcc-patches-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Id: List-Unsubscribe: List-Archive: List-Post: List-Help: Sender: gcc-patches-owner@gcc.gnu.org Delivered-To: mailing list gcc-patches@gcc.gnu.org Received: (qmail 120184 invoked by uid 89); 24 Jan 2019 19:53:15 -0000 Authentication-Results: sourceware.org; auth=none X-Spam-SWARE-Status: No, score=-11.1 required=5.0 tests=BAYES_00, GIT_PATCH_2, GIT_PATCH_3, KAM_ASCII_DIVIDERS, SPF_HELO_PASS, SPF_PASS autolearn=ham version=3.3.2 spammy=H*r:8.14.4, weakness, our X-HELO: aserp2130.oracle.com Received: from aserp2130.oracle.com (HELO aserp2130.oracle.com) (141.146.126.79) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Thu, 24 Jan 2019 19:53:13 +0000 Received: from pps.filterd (aserp2130.oracle.com [127.0.0.1]) by aserp2130.oracle.com (8.16.0.22/8.16.0.22) with SMTP id x0OJnKw7085138; Thu, 24 Jan 2019 19:53:11 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.com; h=to : cc : from : subject : message-id : date : mime-version : content-type; s=corp-2018-07-02; bh=mUNEARn8kwBAC5OlgZokNjf5En0lxakx/6pRxw96rJY=; b=zoaYF4TNiuRQBu2bQRb1NedYFoGEZ20JNLemgcR/SKkaEZrLJDXCB6T78iId1Ws1XG5V MqfnmpCljPnGDD3XH+od5fpmBsN7T/r3z6ggFcIThJejQl9sGQeCndJVLB6Sn0DjqxGq 42YO/RxnKS+4dFsnz518hKdV65S0uMCxTRSwbEZChvA5ieuqJMhIl/2+hDWv/QUU2TnB NNpJImC5sba6K8kPYlM5yBrMhUb5mEXuE/7q1cbFJFmBxZ2eIBEaWI86s2czacLX+0op JPtoyE8I+nsRGqjzba3QL+dqA35XAmOlKKYRXihsZtqRo5IaqH3oDRNkhBV2ghOqGRbC 3w== Received: from aserv0022.oracle.com (aserv0022.oracle.com [141.146.126.234]) by aserp2130.oracle.com with ESMTP id 2q3sdet4p1-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Thu, 24 Jan 2019 19:53:11 +0000 Received: from userv0121.oracle.com (userv0121.oracle.com [156.151.31.72]) by aserv0022.oracle.com (8.14.4/8.14.4) with ESMTP id x0OJrAkW023156 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Thu, 24 Jan 2019 19:53:11 GMT Received: from abhmp0005.oracle.com (abhmp0005.oracle.com [141.146.116.11]) by userv0121.oracle.com (8.14.4/8.13.8) with ESMTP id x0OJrA0L032092; Thu, 24 Jan 2019 19:53:10 GMT Received: from [192.168.1.4] (/79.19.31.237) by default (Oracle Beehive Gateway v4.0) with ESMTP ; Thu, 24 Jan 2019 11:53:10 -0800 To: "gcc-patches@gcc.gnu.org" Cc: Jason Merrill From: Paolo Carlini Subject: [C++ Patch] PR 88969 ("[9 Regression] ICE in build_op_delete_call, at cp/call.c:6509") Message-ID: <7e951363-a1a6-ff72-ae93-ba08ab796616@oracle.com> Date: Thu, 24 Jan 2019 20:53:07 +0100 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:60.0) Gecko/20100101 Thunderbird/60.3.0 MIME-Version: 1.0 X-IsSubscribed: yes Hi, as far as I can see this ICE on invalid points to a substantive, if minor, weakness of our implementation of the destroying operator delete facility: we aren't implementing the bits, per 7.6.2.5/(10.1), about destroying operator delete having precedence over any other operator delete. Thus the below, which is the most straightforward implementation I have been able to figure out given the current infrastructure. Tested x86_64-linux. Thanks, Paolo. //////////////////// /cp 2019-01-24 Paolo Carlini PR c++/88969 * call.c (build_op_delete_call): Implement 7.6.2.5/(10.1). /testsuite 2019-01-24 Paolo Carlini PR c++/88969 * g++.dg/cpp2a/destroying-delete2.C: New. Index: cp/call.c =================================================================== --- cp/call.c (revision 268234) +++ cp/call.c (working copy) @@ -6461,6 +6461,19 @@ build_op_delete_call (enum tree_code code, tree ad continue; } + /* -- If any of the deallocation functions is a destroying + operator delete, all deallocation functions that are not + destroying operator deletes are eliminated from further + consideration. */ + bool fn_destroying = destroying_delete_p (fn); + bool elt_destroying = destroying_delete_p (elt); + if (elt_destroying != fn_destroying) + { + if (elt_destroying) + fn = elt; + continue; + } + /* -- If the type has new-extended alignment, a function with a parameter of type std::align_val_t is preferred; otherwise a function without such a parameter is preferred. If exactly one Index: testsuite/g++.dg/cpp2a/destroying-delete2.C =================================================================== --- testsuite/g++.dg/cpp2a/destroying-delete2.C (nonexistent) +++ testsuite/g++.dg/cpp2a/destroying-delete2.C (working copy) @@ -0,0 +1,20 @@ +// PR c++/88969 +// { dg-do compile { target c++2a } } + +#include + +namespace delete_selection_d { + struct B { + void operator delete(void*) = delete; + void operator delete(B *, std::destroying_delete_t) = delete; // { dg-message "declared here" } + }; + void delete_B(B *b) { delete b; } // { dg-error "use of deleted function" } +} + +namespace delete_selection_r { + struct B { + void operator delete(B *, std::destroying_delete_t) = delete; // { dg-message "declared here" } + void operator delete(void*) = delete; + }; + void delete_B(B *b) { delete b; } // { dg-error "use of deleted function" } +}