From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 81552 invoked by alias); 26 Oct 2015 16:50:44 -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 81538 invoked by uid 89); 26 Oct 2015 16:50:43 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-1.9 required=5.0 tests=AWL,BAYES_00,RP_MATCHES_RCVD,SPF_HELO_PASS autolearn=ham version=3.3.2 X-HELO: mx1.redhat.com Received: from mx1.redhat.com (HELO mx1.redhat.com) (209.132.183.28) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with (AES256-GCM-SHA384 encrypted) ESMTPS; Mon, 26 Oct 2015 16:50:42 +0000 Received: from int-mx14.intmail.prod.int.phx2.redhat.com (int-mx14.intmail.prod.int.phx2.redhat.com [10.5.11.27]) by mx1.redhat.com (Postfix) with ESMTPS id B39B8461EA; Mon, 26 Oct 2015 16:50:41 +0000 (UTC) Received: from [127.0.0.1] (ovpn01.gateway.prod.ext.ams2.redhat.com [10.39.146.11]) by int-mx14.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id t9QGoeh9012164; Mon, 26 Oct 2015 12:50:40 -0400 Message-ID: <562E59DF.9040407@redhat.com> Date: Mon, 26 Oct 2015 23:09:00 -0000 From: Pedro Alves User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:31.0) Gecko/20100101 Thunderbird/31.7.0 MIME-Version: 1.0 To: Simon Marchi , gdb-patches@sourceware.org Subject: Re: [PATCH c++ 12/12] ada-lang.h: Add cast in GROW_VECT References: <1445831362-18789-1-git-send-email-simon.marchi@polymtl.ca> <1445831362-18789-2-git-send-email-simon.marchi@polymtl.ca> In-Reply-To: <1445831362-18789-2-git-send-email-simon.marchi@polymtl.ca> Content-Type: text/plain; charset=windows-1252 Content-Transfer-Encoding: 7bit X-SW-Source: 2015-10/txt/msg00576.txt.bz2 On 10/26/2015 03:49 AM, Simon Marchi wrote: > The assignment requires a cast in C++. > > gdb/ChangeLog: > > * ada-lang.h (GROW_VECT): Add cast. > --- > gdb/ada-lang.h | 2 +- > 1 file changed, 1 insertion(+), 1 deletion(-) > > diff --git a/gdb/ada-lang.h b/gdb/ada-lang.h > index 62896f1..32c4b55 100644 > --- a/gdb/ada-lang.h > +++ b/gdb/ada-lang.h > @@ -147,7 +147,7 @@ struct ada_task_info > least M objects, updating V and S as necessary. */ > > #define GROW_VECT(v, s, m) \ > - if ((s) < (m)) (v) = grow_vect (v, &(s), m, sizeof *(v)); > + if ((s) < (m)) (v) = (typeof (v)) grow_vect (v, &(s), m, sizeof *(v)); > typeof in C is a GCC extension. Probably not all compilers support it. In my branch I just have: #define GROW_VECT(v, s, m) \ - if ((s) < (m)) (v) = grow_vect (v, &(s), m, sizeof *(v)); + if ((s) < (m)) (v) = (char *) grow_vect (v, &(s), m, sizeof *(v)); Because that works for all current uses of GROW_VECT. If we wanted to make this work for random types, then we could add a type parameter to the GROW_VECT macro, like: - #define GROW_VECT(v, s, m) \ - if ((s) < (m)) (v) = grow_vect (v, &(s), m, sizeof *(v)); + #define GROW_VECT(t, v, s, m) \ + if ((s) < (m)) (v) = (t *) grow_vect (v, &(s), m, sizeof *(v)); Not sure it's worth it though. It then raises the question of "why not replace this home grown GROW_VECT stuff with a VEC instead". Thanks, Pedro Alves