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 B179C3858C56 for ; Fri, 12 Apr 2024 21:41:19 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org B179C3858C56 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 B179C3858C56 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=1712958081; cv=none; b=wjELNcSVGAXKjFx1KEtPMufWTyYV/KWaDDD6sxyqR2ojkxxl3FUgEit6KIMppqAcqlYdYHVn6sCdnBJYvV0ppSEmbBp0GYBsNyM8O/Uf/NwrF3Hcjn6Io62BPULwpzUKz9Z/O4ZonMknVRYNRZZUWWkZbihNwz2pB9NCRvfTeNM= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1712958081; c=relaxed/simple; bh=+ew5rpDicB0lQdbpL5SHw81f/spfbUHCsTImQeN4dzo=; h=DKIM-Signature:Date:From:To:Subject:Message-ID:MIME-Version; b=gPacdq0iKvFcHveiKk92htPZRH4QemGL2e00ZFzDpE0zdJd5Z7GE1J//FTj3JxAEbZukvUPlLV+7P1PFGNpwHdcSCUbdnve/QvuOv644LOGI/gMoQaqb0E+LkSR5wGGGGqsjTOJGTkMxlX4avoJktcIR2RdxnpRzcgCs9bMiHG0= ARC-Authentication-Results: i=1; server2.sourceware.org DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1712958079; 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: in-reply-to:in-reply-to:references:references; bh=hTpF8z83Ka7EOGbDWVFkyL6knjNM2Th7VT0wLE6sj18=; b=g684Y9OJ9LtzuqYCsERvroyrafrsYZVyrXN97YdDvOHE4EiEX5wKjpnSLyD2Lu67NoTMfM CQsm2LWWm6qDkDCw7NStHGjaGVeSntfanLM7+/jfEyktOx46IlxFWAbMmPdgXPkXzXQeNI 4LjCncvG8n7+W56EuF1qNDKHax8YJ6Q= 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-135-1_PqthMkMGqljgWGVKNtDg-1; Fri, 12 Apr 2024 17:41:17 -0400 X-MC-Unique: 1_PqthMkMGqljgWGVKNtDg-1 Received: by mail-qv1-f72.google.com with SMTP id 6a1803df08f44-69b62a06757so2813746d6.0 for ; Fri, 12 Apr 2024 14:41:17 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1712958077; x=1713562877; h=user-agent:in-reply-to:content-disposition:mime-version:references :message-id:subject:cc:to:from:date:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=hTpF8z83Ka7EOGbDWVFkyL6knjNM2Th7VT0wLE6sj18=; b=oSkqpENmtDNHua95DCfVw0bxcYpksQP1pbQLmNPE/wB01CHd1O+vmX9QEVQ8KHdgTO RewsOnq8Tu08BozoRaJ2Y13BSXpaygh+YxBaZciINbvTMCh7n3O6uhiDZ+btPhv7li5g kPT2hXDk2vlhLKQJoy5xGNPQwoIZdgmzBfRb4reOhXhAOirNDahznMjMBjiLQjoJaLlY pCilI4QftpgUiTusiZgcmF/d/SEe0S20VvfrveSG5z7esBqTXOhCRaNawif+aoQ2BHSt RJ5OvSrra1XvSggOd773L0fGrHImkiki2+h1AjTAdS+wFPktJ2ttugdzc2jdZ5aAsI1W vPbw== X-Gm-Message-State: AOJu0YyFIbcYc3PiIxkwZYnS8ZxEfNFom0Jz+LX1JYGCP33Sd5cp76Nr 9Skwj7Mi81UwsdRhoh62KqN1xos+zs/iDlicPXrz2BLd9znLAz972a0v+vV/l5/vy/RrdCQWdpR nE9xwqPl6q4rsYxsgcgjR/ZAfZah8UqTVf0K3n3Bt31NjfPpvHrTRmUU= X-Received: by 2002:a05:6214:176c:b0:69b:17b2:df34 with SMTP id et12-20020a056214176c00b0069b17b2df34mr3570132qvb.63.1712958077181; Fri, 12 Apr 2024 14:41:17 -0700 (PDT) X-Google-Smtp-Source: AGHT+IG4vIyc1p5LlgiojhwnWabAnDoGtOpKai93Q2fIgD8Hi6y6cfoHcg+5WQDpsbNZUbm3qR2ZfQ== X-Received: by 2002:a05:6214:176c:b0:69b:17b2:df34 with SMTP id et12-20020a056214176c00b0069b17b2df34mr3570124qvb.63.1712958076876; Fri, 12 Apr 2024 14:41:16 -0700 (PDT) Received: from redhat.com (2603-7000-9500-34a5-0000-0000-0000-1db4.res6.spectrum.com. [2603:7000:9500:34a5::1db4]) by smtp.gmail.com with ESMTPSA id dj12-20020a056214090c00b0069b3bfdea09sm2798526qvb.60.2024.04.12.14.41.16 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 12 Apr 2024 14:41:16 -0700 (PDT) Date: Fri, 12 Apr 2024 17:41:14 -0400 From: Marek Polacek To: Jason Merrill Cc: GCC Patches Subject: Re: [PATCH v3] c++: ICE with temporary of class type in array DMI [PR109966] Message-ID: References: <20240311232758.458729-1-polacek@redhat.com> <2244ac04-8bb6-4030-85c6-7a10aa20c494@redhat.com> <5fd063a8-9406-4b16-8d8d-3c4b3d364abd@redhat.com> MIME-Version: 1.0 In-Reply-To: <5fd063a8-9406-4b16-8d8d-3c4b3d364abd@redhat.com> User-Agent: Mutt/2.2.12 (2023-09-09) X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Type: text/plain; charset=us-ascii Content-Disposition: inline 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 Fri, Apr 12, 2024 at 04:15:45PM -0400, Jason Merrill wrote: > 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. Yeah, happy to; I've opened 114707 to remember. > > 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. Thanks. Marek