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 A01B03858D39 for ; Wed, 28 Feb 2024 23:21:15 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org A01B03858D39 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 A01B03858D39 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=1709162476; cv=none; b=RSad+b8QA48nBO8KM25PfZHKFEuGcSr+TruuL6J937y2BkERBVbmiU2X7G+UegbMgWSejKa5+wL+0lc5vzDoBUBk4I4ZFzWoRWFVPFKNfmgQIZKhKCMXwKSgFuEOyZSdCBHeo7ot4gasGL5ZNwehzjUM8HK90DaRS51NrDm/pFU= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1709162476; c=relaxed/simple; bh=N192tsmHgyv0m6HVhajepnsPtn0i/7ZEdcCp/lip0cA=; h=DKIM-Signature:Message-ID:Date:MIME-Version:Subject:To:From; b=x/ydg2t+UIqxdWF7i1Fi47u/TSly/mBaWT2ivoWGjUjt49Dlcy05jBTx5pZI0kiqrH/WNKv9SYEP3MpxhjbDranXfYR0gFbxJyPJHgB5ydHdRy+/r4RDeVZtkZw74jWpdv+bUOwvUDuvv5VnAGRlRnuKgWjAwLWmMxih2cRXZg0= ARC-Authentication-Results: i=1; server2.sourceware.org DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1709162475; 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=pkQv2H90ZqAVKRK9DA1swK0Dbmu3k0zCQGBey4vUNqg=; b=a7+Rfoh/UgmLjqOpnrfCuyek9Ch5nIIPpZIW4IZkV6Jw/oJnyT0Zl7R+MdE5lcgmX4c0/J VZJb2CyLuiA1+BbjcGH3eUFRe7zrZ0YpUBk+GJjceQZLUoxpfXyFBnEIF9+Oh6w4orvIpf o+X4bs0XIWNiEjwzQ1ejIx/pydyZ/oI= Received: from mail-qv1-f71.google.com (mail-qv1-f71.google.com [209.85.219.71]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-331-hEysux2zM32ILKJanpLUkg-1; Wed, 28 Feb 2024 18:21:12 -0500 X-MC-Unique: hEysux2zM32ILKJanpLUkg-1 Received: by mail-qv1-f71.google.com with SMTP id 6a1803df08f44-6900a373930so2298246d6.0 for ; Wed, 28 Feb 2024 15:21:12 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1709162471; x=1709767271; h=content-transfer-encoding:in-reply-to:from:references:cc:to :content-language:subject:user-agent:mime-version:date:message-id :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=pkQv2H90ZqAVKRK9DA1swK0Dbmu3k0zCQGBey4vUNqg=; b=lzBZdToI1Rmv3d1arFY6aIgF2VIplKkCgcXOrOzOs8R17s0Z//x0CCRrF2aGi/x/rz /hxIxXTvDSWwEmDIuogNWnPWZT+l7By63hERaBmfEzd8PG74yQMkuZjKKr5EPhCZ6LpG TbU0c38bPCaVG5sv3aSrftHRnblcf12vFBhTI4a4ipucZKbGtecFBGh/PjEuQ5eSfLDR /hAVsEDwW3FMf++5XlOBgne13CwDTOoP4PqR7MCCXFAzpKXoPF0RhkPgQJkQBEdShbRd G2r7rBLZhNE16NbXVHlrpUav6BrPmCnQxTsjlAZTSp5moDqFJ0/hKWewzGmljS0Zrrj3 HTBQ== X-Gm-Message-State: AOJu0YyAtkeNecWhIhbC7HtxtAzuSwqf4aa+0Yrcju6RUYCmWpKcCgFH WGjV6cjaD1w8k1KRDqMFjIHXwg5MBPw+v/WQBDoHNxaaqrOkCiTu+ETh3Z2flp+MlLrBX+fhD70 gJ9ho80B501RZwzrmT9Ef/v+8IuGDM/YcdUPswkCLM5S2jjg8f666JNWGInvJ+ro= X-Received: by 2002:a0c:fa4b:0:b0:690:68a:58a4 with SMTP id k11-20020a0cfa4b000000b00690068a58a4mr633360qvo.10.1709162471284; Wed, 28 Feb 2024 15:21:11 -0800 (PST) X-Google-Smtp-Source: AGHT+IGTxbffNOLYBrkPYZwWO3YroBOmASrZIOcYt92Nd0fnDWjcGUWutxMuPvlvl6WItOZ2t+bSMg== X-Received: by 2002:a0c:fa4b:0:b0:690:68a:58a4 with SMTP id k11-20020a0cfa4b000000b00690068a58a4mr633341qvo.10.1709162470966; Wed, 28 Feb 2024 15:21:10 -0800 (PST) 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 oj2-20020a056214440200b006901303d90bsm76197qvb.79.2024.02.28.15.21.10 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Wed, 28 Feb 2024 15:21:10 -0800 (PST) Message-ID: <01d029e0-42e7-4d13-98c0-c251df95d735@redhat.com> Date: Wed, 28 Feb 2024 18:21:09 -0500 MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: [PATCH] c++: -Wuninitialized when binding a ref to uninit DM [PR113987] To: Marek Polacek Cc: GCC Patches References: <20240221001517.478667-1-polacek@redhat.com> <3dae04f1-90b7-4a03-b239-24df37c57cdf@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=-5.6 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,RCVD_IN_SORBS_WEB,SPF_HELO_NONE,SPF_NONE,TXREP,T_SCC_BODY_TEXT_LINE autolearn=no 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 2/22/24 14:28, Marek Polacek wrote: > 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. Fair enough, the patch is OK. Jason