From patchwork Wed Jan 5 12:10:44 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Nathan Sidwell X-Patchwork-Id: 1575624 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: bilbo.ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.a=rsa-sha256 header.s=20210112 header.b=YcGjF4/G; dkim-atps=neutral Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=gcc.gnu.org (client-ip=8.43.85.97; helo=sourceware.org; envelope-from=gcc-patches-bounces+incoming=patchwork.ozlabs.org@gcc.gnu.org; receiver=) Received: from sourceware.org (ip-8-43-85-97.sourceware.org [8.43.85.97]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by bilbo.ozlabs.org (Postfix) with ESMTPS id 4JTTF54zj4z9sPC for ; Wed, 5 Jan 2022 23:24:25 +1100 (AEDT) Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 7917E3858010 for ; Wed, 5 Jan 2022 12:24:23 +0000 (GMT) X-Original-To: gcc-patches@gcc.gnu.org Delivered-To: gcc-patches@gcc.gnu.org Received: from mail-qt1-x82e.google.com (mail-qt1-x82e.google.com [IPv6:2607:f8b0:4864:20::82e]) by sourceware.org (Postfix) with ESMTPS id 80FC1385843A for ; Wed, 5 Jan 2022 12:10:46 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 80FC1385843A Authentication-Results: sourceware.org; dmarc=none (p=none dis=none) header.from=acm.org Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=gmail.com Received: by mail-qt1-x82e.google.com with SMTP id bp39so36988968qtb.6 for ; Wed, 05 Jan 2022 04:10:46 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=sender:message-id:date:mime-version:user-agent:content-language:to :cc:from:subject; bh=Vb6j0ILIn4bAs1yENX87xAaRcz/uzcW1/m2PaHnBk6A=; b=YcGjF4/GVKv2EaSGPFjwqmh3dq4RlF8Nk9oI4ahcgSHEVDMDnbgZn5n5+SCrcSyHze 1Pxcvp4Xz8wCoM3dIuBMOMjP5c8u0x0oenbUmLC/di7iBVR3HFENJxmee+yzfFjJE0/H pIPFv8O7GnX6fOiJQxZbtmFI08R0gdieF26Hir+qiPvr/0THtvQUwuceKjW5kyV4/reD aI0y/6CkJLOaJhw8IzUm3YDSSWY8rnm+pz/sH+kCHz4gceOD+7BRatk53q+gzlCv1Knt MtAPz8qQYZepkxz6jy/ru1C8eR/d6vO5eDTRiVJKpxW2OWPhPsCrjCb8CCQey7j3CdOg ZtYQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:sender:message-id:date:mime-version:user-agent :content-language:to:cc:from:subject; bh=Vb6j0ILIn4bAs1yENX87xAaRcz/uzcW1/m2PaHnBk6A=; b=C8XwlOmmkXhOj3cfYnHkYDBT1Rsl7xeu09xkIJJp3cIRHChMPvf3bxHkqnXu2GoI9J hHDx82Tl1QmmLCmQE4f4hIrL7uJkabPRIoVsDzJsTa3QnefXQb/H5Ip5IFSoJ6cpFUpn 4fpoqs5J0cliipfnP3r+jmcdQWyWEQBb9Jy28Ef5EE8PA35HvMrF1UGfOfnZxNefd2da D5AuWKRIdAjl3WxkXyXnvjDq8My7nwTCwyL2Oo4P1yIto2XgN5kNAKju9jY8qEeJsgEo yGBgGDy4OY4fc02fg7yB0f2jyqMYH6EVxIdArIV8LgRn9Y9qMxP1LsMS0UvmdptwS2eq 89TQ== X-Gm-Message-State: AOAM533CTyz69Z0fpNddyYOFAUntXfRZnGFnOjFR3lO+hNH2NcOZr/ss bUeHJmfsmdXs2AMb5qstvjOFwGK4I+M= X-Google-Smtp-Source: ABdhPJxaT2P13tNxJL7+GRNlTuWx5/esPsR71m6YAk4KmqjJ9/w1r9he8Mjc1C21FXlCGNHdNqwnHg== X-Received: by 2002:a05:622a:112:: with SMTP id u18mr46875541qtw.359.1641384645844; Wed, 05 Jan 2022 04:10:45 -0800 (PST) Received: from ?IPV6:2620:10d:c0a3:1407:af0f:3e7c:6fed:6550? ([2620:10d:c091:500::2:74eb]) by smtp.googlemail.com with ESMTPSA id q27sm26853348qki.100.2022.01.05.04.10.45 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Wed, 05 Jan 2022 04:10:45 -0800 (PST) Message-ID: <20e9265f-7b7b-60a3-d118-5462d964173d@acm.org> Date: Wed, 5 Jan 2022 07:10:44 -0500 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:91.0) Gecko/20100101 Thunderbird/91.2.0 Content-Language: en-US To: GCC Patches From: Nathan Sidwell Subject: Fix diagnostic recursion ICE X-Spam-Status: No, score=-3039.0 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_EF, FREEMAIL_FORGED_FROMDOMAIN, FREEMAIL_FROM, GIT_PATCH_0, HEADER_FROM_DIFFERENT_DOMAINS, RCVD_IN_DNSWL_NONE, SPF_HELO_NONE, SPF_PASS, TXREP autolearn=ham autolearn_force=no version=3.4.4 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) 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: , Errors-To: gcc-patches-bounces+incoming=patchwork.ozlabs.org@gcc.gnu.org Sender: "Gcc-patches" The diagnostic machinery uses template instantiation when generating the [with T = ...] text. In this case that caused an alignment warning to be emitted with a subsequent recursion ICE. pushed to trunk nathan From f2da9e26f5c0f04d48872938eff130e2028e75d3 Mon Sep 17 00:00:00 2001 From: Nathan Sidwell Date: Tue, 4 Jan 2022 12:45:36 -0800 Subject: [PATCH 2/3] Fix diagnostic recursion ICE The [with T = $TYPE] diagnostic machinery must not cause recursion. So let's not unilaterally warn about new alignment. (template extracted from Open3D.) gcc/cp/ * init.c (build_new_1): Check complain before alignment warning. gcc/testsuite/ * g++.dg/diagnostic/recur-align.C: New. --- gcc/cp/init.c | 3 ++- gcc/testsuite/g++.dg/diagnostic/recur-align.C | 19 +++++++++++++++++++ 2 files changed, 21 insertions(+), 1 deletion(-) create mode 100644 gcc/testsuite/g++.dg/diagnostic/recur-align.C diff --git a/gcc/cp/init.c b/gcc/cp/init.c index 3f56ca4bf5e..9d616f3f5e9 100644 --- a/gcc/cp/init.c +++ b/gcc/cp/init.c @@ -3408,7 +3408,8 @@ build_new_1 (vec **placement, tree type, tree nelts, = (type_num_arguments (TREE_TYPE (alloc_fn)) > 1 || varargs_function_p (alloc_fn)); - if (warn_aligned_new + if (complain & tf_warning_or_error + && warn_aligned_new && !placement_allocation_fn_p && TYPE_ALIGN (elt_type) > malloc_alignment () && (warn_aligned_new > 1 diff --git a/gcc/testsuite/g++.dg/diagnostic/recur-align.C b/gcc/testsuite/g++.dg/diagnostic/recur-align.C new file mode 100644 index 00000000000..e7d4b9a17cc --- /dev/null +++ b/gcc/testsuite/g++.dg/diagnostic/recur-align.C @@ -0,0 +1,19 @@ +// ICE with diagnostic recursion +// { dg-do compile { target { c++11_only || c++14_only } } } +// { dg-options -Waligned-new } + +struct __attribute__ ((aligned(256))) Aligned +{ + int b; +}; + +template +auto Foo (const T* x) -> decltype (new T (*x)) +{ + return new T (*x); // { dg-warning "with extended alignment" } +} + +void Bar () { + Aligned y; + Foo (&y); +} -- 2.30.2