From patchwork Tue Oct 17 15:51:20 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Nathan Sidwell X-Patchwork-Id: 827103 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-464344-incoming=patchwork.ozlabs.org@gcc.gnu.org; receiver=) Authentication-Results: ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=gcc.gnu.org header.i=@gcc.gnu.org header.b="oIT0FuQ4"; 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 3yGfnf3Vvpz9t39 for ; Wed, 18 Oct 2017 02:51:34 +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 :from:subject:message-id:date:mime-version:content-type; q=dns; s=default; b=hdh2eokFGXwydGLsVlp4iHBvJH1k1FVxLZFqftEUeuW4IqW/ZS +82dGtXNo1V5tOCmNVX1bgQV1JevedipbfOm0U0xvJREnv35vLNeu2c07/BRg00/ oXFCfmxXexXrwX9eGZZ5M+4QMPw0AYznLFM/dHaqlvTyzpQ8+nbt3TUJw= 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 :from:subject:message-id:date:mime-version:content-type; s= default; bh=qZ3EG/Odw/sfAXnaliRldD5QD+M=; b=oIT0FuQ4KvyohUNas0lI MjJYVDzzuNE0TJ0DixtnULI9/qerR+uGVuQBmfk70FoF458JD4z38gzqKLtf92UK fOektILQBegTtNZbVyvnNCQRg8Yj82cF3nGGwKJrh2fafyQ2URRbOCJqF5u2CmAV TXaW0SJtlIY77zycPAnMcLU= Received: (qmail 25458 invoked by alias); 17 Oct 2017 15:51:27 -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 25406 invoked by uid 89); 17 Oct 2017 15:51:26 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-11.1 required=5.0 tests=BAYES_00, FREEMAIL_FROM, GIT_PATCH_2, GIT_PATCH_3, KAM_ASCII_DIVIDERS, RCVD_IN_DNSWL_NONE, SPF_PASS autolearn=ham version=3.3.2 spammy=HX-Google-Smtp-Source:AOwi7QB X-HELO: mail-pf0-f170.google.com Received: from mail-pf0-f170.google.com (HELO mail-pf0-f170.google.com) (209.85.192.170) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Tue, 17 Oct 2017 15:51:24 +0000 Received: by mail-pf0-f170.google.com with SMTP id t188so1633179pfd.10 for ; Tue, 17 Oct 2017 08:51:24 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:sender:to:from:subject:message-id:date :user-agent:mime-version:content-language; bh=HPMyZxznaxGOh+0rC8VzVIhDkJ+LhDxLazb+ZTcD5mk=; b=Vs1W2g27Yl37FUBVki7+GQ9CQU/tSET31+gNBBchmL24+bLh9fuVCej5+cfRIZb5w7 oJ4Udy60Nb04IsUySF3Q44bx6LZoEeoaD7zYRHvT+o4f1bjHc9PQf/n0tEmk1QcpWAWT SD91SDRJU4km3Wm3hb4Zhsf0qI5+Mt1SFKWJSfocmR6wMIiJMNqBuPBWXmygsSUAAazE sUwEi2StWIswCYiJUb61Cd5138kC1+l3w6FYIzpgVzKmyKnFi1X/L/Yat7cgJrZOE6n+ /tvJa6nAgqZhmh/s0+MT/yoSrODjLlOCoXFlNbj5JUXsGfIFNjeQTdnJESjnYwtFRo6k TBCA== X-Gm-Message-State: AMCzsaViPwqdH79c82Wz8i5x2YXEkP5gm9xlc+vJ7mH7vlAeZM8iDngj K8EmGfzmOXkAKe3IyG4EC3M= X-Google-Smtp-Source: AOwi7QB+3Tv6Z0LtlMrWYtsaAXRJNSqDAR13dQmU45FwlNFgECTQgth+buvLBsBkDsn1ki4gr+F9PQ== X-Received: by 10.99.102.6 with SMTP id a6mr10983475pgc.298.1508255483231; Tue, 17 Oct 2017 08:51:23 -0700 (PDT) Received: from ?IPv6:2620:10d:c082:1055:31e1:4d57:79ff:da5a? ([2620:10d:c090:200::5:301b]) by smtp.googlemail.com with ESMTPSA id l79sm21785992pfb.33.2017.10.17.08.51.22 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 17 Oct 2017 08:51:22 -0700 (PDT) To: GCC Patches From: Nathan Sidwell Subject: [C++ PATCH 82560] missing dtor call Message-ID: Date: Tue, 17 Oct 2017 11:51:20 -0400 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101 Thunderbird/52.3.0 MIME-Version: 1.0 In a 'new T(whatever)' expression, we'll never call T::~T. We used to generate such a cleanup (but then throw it away in optimization). But now dtors can be deleted, so that approach could fail. My patch for 78469 fixed that. But caused this problem. The only cleanup we should not be generating is for the object being newed. Like the decltype handling in build_new_method_call, we shouldn't be passing no_cleanup down either. Applying to trunk. nathan 2017-10-17 Nathan Sidwell PR c++/82560 * call.c (build_over_call): Don't pass tf_no_cleanup to nested calls. PR c++/82560 * g++.dg/cpp0x/pr82560.C: New. Index: cp/call.c =================================================================== --- cp/call.c (revision 253819) +++ cp/call.c (working copy) @@ -7717,8 +7717,11 @@ build_over_call (struct z_candidate *can } /* N3276 magic doesn't apply to nested calls. */ - int decltype_flag = (complain & tf_decltype); + tsubst_flags_t decltype_flag = (complain & tf_decltype); complain &= ~tf_decltype; + /* No-Cleanup doesn't apply to nested calls either. */ + tsubst_flags_t no_cleanup_complain = complain; + complain &= ~tf_no_cleanup; /* Find maximum size of vector to hold converted arguments. */ parmlen = list_length (parm); @@ -7916,7 +7919,7 @@ build_over_call (struct z_candidate *can if (flags & LOOKUP_NO_CONVERSION) conv->user_conv_p = true; - tsubst_flags_t arg_complain = complain & (~tf_no_cleanup); + tsubst_flags_t arg_complain = complain; if (!conversion_warning) arg_complain &= ~tf_warning; @@ -8164,7 +8167,8 @@ build_over_call (struct z_candidate *can else if (default_ctor_p (fn)) { if (is_dummy_object (argarray[0])) - return force_target_expr (DECL_CONTEXT (fn), void_node, complain); + return force_target_expr (DECL_CONTEXT (fn), void_node, + no_cleanup_complain); else return cp_build_indirect_ref (argarray[0], RO_NULL, complain); } @@ -9062,7 +9066,6 @@ build_new_method_call_1 (tree instance, static member function. */ instance = mark_type_use (instance); - /* Figure out whether to skip the first argument for the error message we will display to users if an error occurs. We don't want to display any compiler-generated arguments. The "this" Index: testsuite/g++.dg/cpp0x/pr82560.C =================================================================== --- testsuite/g++.dg/cpp0x/pr82560.C (revision 0) +++ testsuite/g++.dg/cpp0x/pr82560.C (working copy) @@ -0,0 +1,28 @@ +// { dg-do run { target c++11 } } +// PR82560, failed to destruct default arg inside new + +static int liveness = 0; + +struct Foo { + + Foo (int) { + liveness++; + } + + ~Foo() { + liveness--; + } + +}; + +struct Bar { + Bar (Foo = 0) { } + ~Bar() { } +}; + +int main() +{ + delete new Bar(); + + return liveness != 0;; +}