From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 15811 invoked by alias); 10 Nov 2011 23:24:27 -0000 Received: (qmail 15793 invoked by uid 22791); 10 Nov 2011 23:24:26 -0000 X-SWARE-Spam-Status: No, hits=-2.5 required=5.0 tests=AWL,BAYES_00,DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FROM,RCVD_IN_DNSWL_LOW X-Spam-Check-By: sourceware.org Received: from mail-wy0-f175.google.com (HELO mail-wy0-f175.google.com) (74.125.82.175) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Thu, 10 Nov 2011 23:24:13 +0000 Received: by wyh5 with SMTP id 5so3715789wyh.20 for ; Thu, 10 Nov 2011 15:24:12 -0800 (PST) MIME-Version: 1.0 Received: by 10.216.54.83 with SMTP id h61mr33965wec.6.1320967451994; Thu, 10 Nov 2011 15:24:11 -0800 (PST) Received: by 10.216.63.83 with HTTP; Thu, 10 Nov 2011 15:24:11 -0800 (PST) In-Reply-To: <4EBC315C.1030309@redhat.com> References: <4EB851F2.4090107@redhat.com> <4EBC2FA7.1000504@redhat.com> <4EBC315C.1030309@redhat.com> Date: Fri, 11 Nov 2011 00:00:00 -0000 Message-ID: Subject: Re: [patch] c++/2972 warn when ctor-initializer leaves uninitialized data From: Jonathan Wakely To: Jason Merrill Cc: gcc-patches Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable Mailing-List: contact gcc-patches-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Id: List-Archive: List-Post: List-Help: Sender: gcc-patches-owner@gcc.gnu.org X-SW-Source: 2011-11/txt/msg01481.txt.bz2 On 10 November 2011 20:17, Jason Merrill wrote: > On 11/10/2011 03:10 PM, Jason Merrill wrote: >> >> On 11/10/2011 02:48 PM, Jonathan Wakely wrote: >>> >>> +warn_missing_meminits (tree type, tree cons) >>> +{ >>> + tree mem_inits =3D sort_mem_initializers (type, NULL_TREE); >>> + while (mem_inits) >>> + { >>> + tree member =3D TREE_PURPOSE (mem_inits); >>> + /* TODO do not warn if brace-or-equal-initializer */ >>> + warn_meminit_leaves_uninitialized (member, TREE_TYPE (member), cons); >>> + mem_inits =3D TREE_CHAIN (mem_inits); >>> + } >>> +} >> >> Check DECL_INITIAL (member) to tell if it has an NSDMI. > > Actually, why not just use default_init_uninitialized_part (type)? > >> + =A0if (warn_meminit && (kind =3D=3D sfk_constructor || kind =3D=3D >> sfk_copy_constructor >> + =A0 =A0 =A0 =A0|| kind =3D=3D sfk_move_constructor)) >> + =A0 =A0warn_missing_meminits (current_class_type, fn); > > We only want to do this for sfk_constructor; the others initialize all > fields. Doh, of course. Thanks for the pointers, I'll have another stab at it. I really want to get this warning implemented eventually.