From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 127506 invoked by alias); 13 Apr 2017 02:36:25 -0000 Mailing-List: contact gdb-patches-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: gdb-patches-owner@sourceware.org Received: (qmail 125976 invoked by uid 89); 13 Apr 2017 02:36:22 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-2.5 required=5.0 tests=AWL,BAYES_00,RCVD_IN_DNSWL_NONE autolearn=ham version=3.3.2 spammy= X-HELO: mail-wr0-f177.google.com Received: from mail-wr0-f177.google.com (HELO mail-wr0-f177.google.com) (209.85.128.177) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Thu, 13 Apr 2017 02:36:21 +0000 Received: by mail-wr0-f177.google.com with SMTP id l28so27440532wre.0 for ; Wed, 12 Apr 2017 19:36:22 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:subject:to:references:cc:from:message-id:date :user-agent:mime-version:in-reply-to:content-transfer-encoding; bh=E53v88v1ImEACHUDaA9Q9FuJhmm/oEjSriSNJnDfxps=; b=kHIvxaIWARtwa9ULmObwsmXeUczOd7T4i08jc4u8mBXCDIJZkIZrb8MdR8+frZv7WI L82HmiuqVus0Jto5p7sYJRHOmwZpXFgzOkYZDp7n7SCJCH7ZnTsLaIPk8Qn11xWbzWYB K/7+HWcWrDpffDGzNhwzhUQ3+C35/6Ss3HMGR2y+tA+8c1u+4wjK14mRms9lAnakKTRN r8RkmtgEPV1xGQQFiWjDwbm23qTLPoYBXYuXjFii8KRr9/v2PQN6tX1IV8r6iyaP2Q8P yaOXtsPa6pwZQXM/ZO5L1AfMeryYMM6MVcRGSYe2tj9o70ht38vgbpLr70t30AOfdS+x eMPQ== X-Gm-Message-State: AN3rC/5bzA9aCb3cd5t7GH8OSKjr9Y4JrV/lb2erfNR5FY5KsqMMga8D rK7tHqC+zyaO8fO2kgQs8Q== X-Received: by 10.223.164.137 with SMTP id g9mr585900wrb.92.1492050980748; Wed, 12 Apr 2017 19:36:20 -0700 (PDT) Received: from [192.168.0.101] ([37.189.166.198]) by smtp.gmail.com with ESMTPSA id c8sm27712821wrd.57.2017.04.12.19.36.19 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 12 Apr 2017 19:36:19 -0700 (PDT) Subject: Re: [RFA v2 10/17] C++ify mi_parse To: Tom Tromey References: <20170411150112.23207-1-tom@tromey.com> <20170411150112.23207-11-tom@tromey.com> <56430d1d-abb1-5e22-87dd-14158939d842@redhat.com> <87y3v561rm.fsf@tromey.com> <59b6549f-3232-64c0-2f3c-5469f1f3ca6f@redhat.com> <87tw5t5wnl.fsf@tromey.com> <77601650-1ad9-dc6e-b7a2-814a08f9348d@redhat.com> <87pogh5sxs.fsf@tromey.com> Cc: gdb-patches@sourceware.org From: Pedro Alves Message-ID: <396349bf-423d-da66-8b14-95dd86b6b148@redhat.com> Date: Thu, 13 Apr 2017 02:36:00 -0000 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:45.0) Gecko/20100101 Thunderbird/45.4.0 MIME-Version: 1.0 In-Reply-To: <87pogh5sxs.fsf@tromey.com> Content-Type: text/plain; charset=windows-1252 Content-Transfer-Encoding: 7bit X-SW-Source: 2017-04/txt/msg00384.txt.bz2 On 04/12/2017 08:25 PM, Tom Tromey wrote: >>>>>> "Pedro" == Pedro Alves writes: > > Pedro> FYI, I just now tried the hack below against master, and > Pedro> that caught a few other cases that shouldn't have been > Pedro> using memset for initialization. > [...] > Pedro> I wonder how bad would it be to put this hack in master. Guess > Pedro> we could always add it behind an #if 0 at least, to make it easy > Pedro> to enable for quick checking? > > I think it would be helpful if the compiler could warn about missing > member initializations in a constructor. Yeah, that would be nice. In principle, -Wuninitialized would catch those too, and be quiet if you have some field that you do want to be left uninitialized in the ctor (e.g., some big array lazily filled in). (And for OOL ctors, there's -flto.) There are unfortunately a number of bugs with it, though. The last I ran into was: https://gcc.gnu.org/bugzilla/show_bug.cgi?id=79658 > That would make something like > the mi_parse change more robust, which I think is the reason for the > memsets in the first place. Yeah. The memsets become invalid as soon as your ctor does something non-trivial though, we really need to zap them sooner than later. My current thinking is that in-class initialization helps by making it easier to check whether all fields have default initialization. I've posted a series fixing the issues the hack caught, and some more, along with a better version of the hack, here: https://sourceware.org/ml/gdb-patches/2017-04/msg00378.html Thanks, Pedro Alves