From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 31908 invoked by alias); 20 Apr 2017 04:00:48 -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 9687 invoked by uid 89); 20 Apr 2017 03:58:46 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-23.9 required=5.0 tests=AWL,BAYES_00,GIT_PATCH_0,GIT_PATCH_1,GIT_PATCH_2,GIT_PATCH_3,SPF_HELO_PASS,SPF_SOFTFAIL autolearn=ham version=3.3.2 spammy= X-HELO: simark.ca Received: from simark.ca (HELO simark.ca) (158.69.221.121) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Thu, 20 Apr 2017 03:58:44 +0000 Received: by simark.ca (Postfix, from userid 33) id 6F9C81E48D; Wed, 19 Apr 2017 23:58:44 -0400 (EDT) To: Pedro Alves Subject: Re: [PATCH 5/5] Don't memset non-POD types: struct breakpoint X-PHP-Originating-Script: 33:rcube.php MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 8bit Date: Thu, 20 Apr 2017 04:00:00 -0000 From: Simon Marchi Cc: gdb-patches@sourceware.org In-Reply-To: <1492050475-9238-6-git-send-email-palves@redhat.com> References: <1492050475-9238-1-git-send-email-palves@redhat.com> <1492050475-9238-6-git-send-email-palves@redhat.com> Message-ID: <97e100ef6f6427505651a2c2a90b675a@polymtl.ca> X-Sender: simon.marchi@polymtl.ca User-Agent: Roundcube Webmail/1.2.4 X-IsSubscribed: yes X-SW-Source: 2017-04/txt/msg00578.txt.bz2 On 2017-04-12 22:27, Pedro Alves wrote: > Eh, struct breakpoint was made non-POD just today, with commit > d28cd78ad820e3 ("Change breakpoint event locations to > event_location_up"). :-) > > src/gdb/breakpoint.c: In function ‘void > init_raw_breakpoint_without_location(breakpoint*, gdbarch*, bptype, > const breakpoint_ops*)’: > src/gdb/breakpoint.c:7447:28: error: use of deleted function ‘void* > memset(T*, int, size_t) [with T = breakpoint; > = void; size_t = long unsigned int]’ > memset (b, 0, sizeof (*b)); > ^ > In file included from src/gdb/common/common-defs.h:85:0, > from src/gdb/defs.h:28, > from src/gdb/breakpoint.c:20: > src/gdb/common/poison.h:56:7: note: declared here > void *memset (T *s, int c, size_t n) = delete; > ^ > > gdb/ChangeLog: > yyyy-mm-dd Pedro Alves > > * breakpoint.h (struct breakpoint): In-class initialize all > fields. Make boolean fields "bool". > * breakpoint.c (init_raw_breakpoint_without_location): Remove > memset call and initializations no longer necessary. > --- > gdb/breakpoint.c | 10 ---------- > gdb/breakpoint.h | 60 > ++++++++++++++++++++++++++++---------------------------- > 2 files changed, 30 insertions(+), 40 deletions(-) > > diff --git a/gdb/breakpoint.c b/gdb/breakpoint.c > index 0796313..0e6aecc 100644 > --- a/gdb/breakpoint.c > +++ b/gdb/breakpoint.c > @@ -7444,8 +7444,6 @@ init_raw_breakpoint_without_location (struct > breakpoint *b, > enum bptype bptype, > const struct breakpoint_ops *ops) > { > - memset (b, 0, sizeof (*b)); > - > gdb_assert (ops != NULL); > > b->ops = ops; > @@ -7453,17 +7451,9 @@ init_raw_breakpoint_without_location (struct > breakpoint *b, > b->gdbarch = gdbarch; > b->language = current_language->la_language; > b->input_radix = input_radix; > - b->thread = -1; > b->enable_state = bp_enabled; Is there a reason you don't assign bp_enabled in-class directly? > - b->next = 0; > - b->silent = 0; > - b->ignore_count = 0; > - b->commands = NULL; > b->frame_id = null_frame_id; I think you can remove the assignment to frame_id, since it's done in-class. > - b->condition_not_parsed = 0; > - b->py_bp_object = NULL; > b->related_breakpoint = b; > - b->location = NULL; > } > > /* Helper to set_raw_breakpoint below. Creates a breakpoint > diff --git a/gdb/breakpoint.h b/gdb/breakpoint.h > index 18b284f..ae84349 100644 > --- a/gdb/breakpoint.h > +++ b/gdb/breakpoint.h > @@ -681,45 +681,45 @@ extern int target_exact_watchpoints; > struct breakpoint > { > /* Methods associated with this breakpoint. */ > - const struct breakpoint_ops *ops; > + const breakpoint_ops *ops = NULL; > > - struct breakpoint *next; > + breakpoint *next = NULL; > /* Type of breakpoint. */ > - enum bptype type; > + bptype type {bp_none}; For consistency, I think it would be nice to use = when possible bptype type = bp_none;