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 0C3BA3858416 for ; Thu, 22 Feb 2024 19:29:06 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 0C3BA3858416 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 0C3BA3858416 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=1708630148; cv=none; b=x2jt2QPONCsMnzpAtSTbbZuPNaTQ3d6WqlhltxKuxk4kP4t1TtwS+3xJvWrdsW+xTdF6RRGe8w1eVPlto0firxBuvBSIm6ia02BXJkmXg7CDyaQ+lSHcR6SAe1k5vdCqP6kRsJ9VdZ+5QGqbN3t1hGTCQdP2yQOl16tN501piME= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1708630148; c=relaxed/simple; bh=DPpU9MdlMvmGX4sAVs2RqU0RncZBLBeaPR+IFgLDyoE=; h=DKIM-Signature:Date:From:To:Subject:Message-ID:MIME-Version; b=FYsemcD3/bEKS/l3vWBWXIanE3LhWfO6xsd6iv9oMZz6GI5kXGKoexOVygLi4K5Z5LolATh7PcrJcli2IUN7Y+JnHrVLnbcI645NqXCqkdprwjZZ8HmC9fEZYEfvjh8h9UuNSHLG3IRT3T0COKgS3sNA6QBuJo9SUkynpH9ZrWA= ARC-Authentication-Results: i=1; server2.sourceware.org DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1708630145; 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=dlH/liTOpG4goTm+4Q/udf1BWhQxcfuPZrVrGn1AQIE=; b=VBa4J34Q3g8r1bHJbiIMxRr0yUpr2LgznFIlUnagTFfbvYrYl2zd0GvdiI0A374QHMsVsJ aC10BvsJRxN5olZgluzHY843TQd20ZVImSWCXIR2i+tuxrW6eTeuMSB9iXyYG8I4+gyT9k fm8qB39o0S01wrcDdmYSN/9jkP1Uekg= Received: from mail-yw1-f199.google.com (mail-yw1-f199.google.com [209.85.128.199]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-593-aeKEuYqTMMaRnPLGwA3P8w-1; Thu, 22 Feb 2024 14:29:04 -0500 X-MC-Unique: aeKEuYqTMMaRnPLGwA3P8w-1 Received: by mail-yw1-f199.google.com with SMTP id 00721157ae682-608b3251948so1591687b3.3 for ; Thu, 22 Feb 2024 11:29:04 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1708630124; x=1709234924; 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=dlH/liTOpG4goTm+4Q/udf1BWhQxcfuPZrVrGn1AQIE=; b=c2i9IR53VQPEJJ+oWN3djTSCLs7RC53ZaMfId6BiDbG9D9NKR5lK+B4v8sgj4Pyp7i +J6hZu1J76IKfWtkPuY0JKJpe5Tdkgfg3SU3grAVakOTerKF4C315DnxJ+ouxoPQ4CPa srcLx5Y+sVQBut6eFmwBpYOk64YwiS1pdEKMUu9/mVRdo5eJGVPmy3iJD7WqEyMdLIr/ bVL7cTtUAPhTEcKcQ45rWpke64EnBixERMVVyR9ahGnHjT+qG7WtGBiHgoo+nUyQUB18 dJKuuSHbmdmwvi25agEhhhEc/P+L/8NU1H42+eOLjcn+WlO6guPM6iGwJ5DNgj6DV1BC AcYA== X-Gm-Message-State: AOJu0YwvkdaOtK/2HHyzYc1gUacVMoUL9Fjg/HyG69p2FQN4aqvaOMo9 4R/5gvC45L5NysKbZJWpWhAlARWUATdy07PxppwHLL7wH7s4FZQTcgR/FLRYcbxLgvfH50r3x8/ OCxJj6mGzvx5an8WFMgaiE1atEzhTO4UfXYR1vLcqShYfKmIqF0HaBVk= X-Received: by 2002:a0d:ea56:0:b0:608:231e:adca with SMTP id t83-20020a0dea56000000b00608231eadcamr144444ywe.4.1708630124467; Thu, 22 Feb 2024 11:28:44 -0800 (PST) X-Google-Smtp-Source: AGHT+IGCbAKM1nny1YgawBq39uLpMG1b2ampgVGZcDRDfmQ7z4B+ZbA6K3cc+Bqvs+R48HThTPgKFg== X-Received: by 2002:a0d:ea56:0:b0:608:231e:adca with SMTP id t83-20020a0dea56000000b00608231eadcamr144430ywe.4.1708630124139; Thu, 22 Feb 2024 11:28:44 -0800 (PST) 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 bl5-20020a05620a1a8500b007879e6fea9fsm872265qkb.14.2024.02.22.11.28.43 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 22 Feb 2024 11:28:43 -0800 (PST) Date: Thu, 22 Feb 2024 14:28:41 -0500 From: Marek Polacek To: Jason Merrill Cc: GCC Patches Subject: Re: [PATCH] c++: -Wuninitialized when binding a ref to uninit DM [PR113987] Message-ID: References: <20240221001517.478667-1-polacek@redhat.com> <3dae04f1-90b7-4a03-b239-24df37c57cdf@redhat.com> MIME-Version: 1.0 In-Reply-To: <3dae04f1-90b7-4a03-b239-24df37c57cdf@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=-6.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_H2,SPF_HELO_NONE,SPF_NONE,TXREP,T_SCC_BODY_TEXT_LINE 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 Thu, Feb 22, 2024 at 08:34:45AM +0000, Jason Merrill wrote: > On 2/20/24 19:15, Marek Polacek wrote: > > Bootstrapped/regtested on x86_64-pc-linux-gnu, ok for trunk? > > > > -- >8 -- > > This PR asks that our -Wuninitialized for mem-initializers does > > not warn when binding a reference to an uninitialized data member. > > We already check !INDIRECT_TYPE_P in find_uninit_fields_r, but > > that won't catch binding a parameter of a reference type to an > > uninitialized field, as in: > > > > struct S { S (int&); }; > > struct T { > > T() : s(i) {} > > S s; > > int i; > > }; > > > > This patch adds a new function to handle this case. > > For type_build_ctor_call types like S, it's weird that we currently > find_uninit_fields before building the initialization. What if we move the > check after the build_aggr_init so we have the actual initializer instead of > just the expression? Thanks. I've tried but unfortunately I'm not getting anywhere. One problem is that immediately after the find_uninit_fields call we may change the TREE_LIST in if (init && TREE_CODE (init) == TREE_LIST) //... so we'd have to cope with that somehow. Sinking find_uninit_fields into one of the conditions below looks like a complication. Another problem is that calling find_uninit_fields on the result of build_aggr_init call causes a bogus warning: we create something like E::E (&((struct F *) this)->e, ((struct F *) this)->a) and then warn that the this object is uninitialized. So I'm not sure if that fix would be simpler. Marek