From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by sourceware.org (Postfix) with ESMTPS id BA0953858C56 for ; Fri, 12 Apr 2024 20:15:49 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org BA0953858C56 Authentication-Results: sourceware.org; dmarc=pass (p=none dis=none) header.from=redhat.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=redhat.com ARC-Filter: OpenARC Filter v1.0.0 sourceware.org BA0953858C56 Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=170.10.129.124 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1712952951; cv=none; b=rn+v33fem4JfQ1quzYE/Ze5rN/3p503M0rbHWOogyuWjSS2Nj+HsG6/7R26LyFPaDgkK4hcKOGHgbLMOBwc/EpJrX0mKa0TBJ+Bg6k/pA6NMzuefDTIP788/8PrDgmMdslZ2MprksPtJSHyfeZhJGjFVlA77h23rGkyEgUKc0xs= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1712952951; c=relaxed/simple; bh=Dc2M8d3w5mn6Zo7g3QX9sMSa4tsF+lUA0lsocTrBshM=; h=DKIM-Signature:Message-ID:Date:MIME-Version:Subject:To:From; b=r7EloQBH8V7HPdyMNIaIuRL9RmqGg/4PpnDtYFjfRPHIq5fCyHEyRbNgdLOB50+bxCSiklwh+KP0Jum1nidehHAvTh+oYJcAH3GSS9sggbiKdCpk/yLuwdGswRi5qKY2Mm7BNNuhkgYhSCV67goykupbbBq4QNWZPDRSm4b2fuw= ARC-Authentication-Results: i=1; server2.sourceware.org DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1712952949; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=7mD1ekfEsXG9TM0go9EqbiDiDtlB/jEhsFG85LBKa3g=; b=VhD7I+YrCd14afF+a0T+Scg91emRuRV16jdjO1Y/EAb7QDOfmrQc5Q836pIDv1NLNsbrDP cHTqaypbtY6NF7vGlBKFl4aB13O0IKonWzut/i3nRZ6iUoGQBT9J7Y6nSEmxjji8pjO0QX aoInuFN0VnsHqo2L/hpYq+tn5OiCQ5A= Received: from mail-qv1-f72.google.com (mail-qv1-f72.google.com [209.85.219.72]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-353-fahP1ApWNh6ONx-srNc20g-1; Fri, 12 Apr 2024 16:15:48 -0400 X-MC-Unique: fahP1ApWNh6ONx-srNc20g-1 Received: by mail-qv1-f72.google.com with SMTP id 6a1803df08f44-69b20caadcaso12319866d6.0 for ; Fri, 12 Apr 2024 13:15:47 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1712952947; x=1713557747; h=content-transfer-encoding:in-reply-to:from:content-language :references:cc:to:subject:user-agent:mime-version:date:message-id :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=7mD1ekfEsXG9TM0go9EqbiDiDtlB/jEhsFG85LBKa3g=; b=jYzlYBZCjum7bstzwRl1kvQFaGSmskwgcRDJTuuOPRBfo9bqkbYrM/XFAt1D2Bz9d8 O+9Kn5ZQJaDL0bb3BZZPXAvbkz2L53v2IWL3j5iZl63UQjV05vgSMLNbFMFcSAKJyDOj wf783GY41/SPVYyaSYYKFtdykrW6IbWgDldAp/1lnEefX64XtakhFQTRsGhzm2lktKe5 gByaYWDT3b8Wrg5P0rEJ7lOoWoLjYkzdn2622dS0FC0HFPRZ3GC28Sn64VB4xLkzB1kw Q/yu1L4wqoacy2qECdCTZRTqJV2i1bMYoaMwj+iHm1AB3k8U60rl5FDTVhKOmdjlmW5w gm+A== X-Gm-Message-State: AOJu0YwxERkPNPqLZimdduDVwsdrleYBQBTN7M5zSEGeYegC510hs+uU wi3b5bR8gbjrOaZuEE1WgU5o9e8estcneTs2nrzUeE76ATe/3GCk8bFAh/dC56EhjAz2cHRWfTs XuqsUClUkLD83nkizUYWCI3Yo8cJv0OkqkaORHz9FD7n0cjE41TJK4xCI5H62tlI= X-Received: by 2002:a0c:f00f:0:b0:69b:3286:de2 with SMTP id z15-20020a0cf00f000000b0069b32860de2mr3750008qvk.59.1712952947289; Fri, 12 Apr 2024 13:15:47 -0700 (PDT) X-Google-Smtp-Source: AGHT+IG6RVOl/y8fmAAj24VTa4MrSuI5NpR5VQ9Bw6Om/SKGd5hIXhgIQFi0tpXoJQC9y7Ubq/q2YA== X-Received: by 2002:a0c:f00f:0:b0:69b:3286:de2 with SMTP id z15-20020a0cf00f000000b0069b32860de2mr3750000qvk.59.1712952947008; Fri, 12 Apr 2024 13:15:47 -0700 (PDT) Received: from [192.168.1.130] (130-44-146-16.s12558.c3-0.arl-cbr1.sbo-arl.ma.cable.rcncustomer.com. [130.44.146.16]) by smtp.gmail.com with ESMTPSA id kk22-20020a056214509600b0069b23dd33besm2736086qvb.126.2024.04.12.13.15.46 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Fri, 12 Apr 2024 13:15:46 -0700 (PDT) Message-ID: <5fd063a8-9406-4b16-8d8d-3c4b3d364abd@redhat.com> Date: Fri, 12 Apr 2024 16:15:45 -0400 MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: [PATCH v3] c++: ICE with temporary of class type in array DMI [PR109966] To: Marek Polacek Cc: GCC Patches References: <20240311232758.458729-1-polacek@redhat.com> <2244ac04-8bb6-4030-85c6-7a10aa20c494@redhat.com> From: Jason Merrill In-Reply-To: X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Language: en-US Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit X-Spam-Status: No, score=-7.3 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH,DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_NONE,RCVD_IN_MSPIKE_H4,RCVD_IN_MSPIKE_WL,SPF_HELO_NONE,SPF_NONE,TXREP autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org List-Id: On 3/14/24 17:26, Marek Polacek wrote: > > In the following patch, I'm taking a different tack. I believe > we ought to use TARGET_EXPR_ELIDING_P. The gimplify_arg bit I'm > talking about below is this: > > /* Also strip a TARGET_EXPR that would force an extra copy. */ > if (TREE_CODE (*arg_p) == TARGET_EXPR) > { > tree init = TARGET_EXPR_INITIAL (*arg_p); > if (init > && !VOID_TYPE_P (TREE_TYPE (init))) > *arg_p = init; > } > > Bootstrapped/regtested on x86_64-pc-linux-gnu, ok for trunk/13? > > -- >8 -- > This ICE started with the fairly complicated r13-765. We crash in > gimplify_var_or_parm_decl because a stray VAR_DECL leaked there. > The problem is ultimately that potential_prvalue_result_of wasn't > correctly handling arrays and replace_placeholders_for_class_temp_r > replaced a PLACEHOLDER_EXPR in a TARGET_EXPR which is used in the > context of copy elision. If I have > > M m[2] = { M{""}, M{""} }; > > then we don't invoke the M(const M&) copy-ctor. > > One part of the fix is to use TARGET_EXPR_ELIDING_P rather than > potential_prvalue_result_of. That unfortunately doesn't handle the > case like > > struct N { N(M); }; > N arr[2] = { M{""}, M{""} }; > > because TARGET_EXPRs that initialize a function argument are not > marked TARGET_EXPR_ELIDING_P even though gimplify_arg drops such > TARGET_EXPRs on the floor. We can use a pset to avoid replacing > placeholders in them. > > I made an attempt to use set_target_expr_eliding in > convert_for_arg_passing but that regressed constexpr-diag1.C, and does > not seem like a prudent change in stage 4 anyway. I tried the same thing to see what you mean, and that doesn't look like a regression to me, just a different (and more accurate) diagnostic. But you're right that this patch is safer, and the other approach can wait for stage 1. Will you queue that up? In the mean time, this patch is OK. > I just realized this could also check !TARGET_EXPR_ELIDING_P; there's no point > to adding an eliding TARGET_EXPR into the pset. ...with this change. Jason