From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 80064 invoked by alias); 27 Oct 2015 02:34:59 -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 80046 invoked by uid 89); 27 Oct 2015 02:34:58 -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,FREEMAIL_FROM,RCVD_IN_DNSWL_LOW,SPF_PASS autolearn=ham version=3.3.2 X-HELO: mail-qg0-f45.google.com Received: from mail-qg0-f45.google.com (HELO mail-qg0-f45.google.com) (209.85.192.45) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with (AES128-GCM-SHA256 encrypted) ESMTPS; Tue, 27 Oct 2015 02:34:56 +0000 Received: by qgad10 with SMTP id d10so136171146qga.3 for ; Mon, 26 Oct 2015 19:34:54 -0700 (PDT) X-Received: by 10.140.151.140 with SMTP id 134mr48108727qhx.25.1445913294799; Mon, 26 Oct 2015 19:34:54 -0700 (PDT) Received: from [10.0.0.136] (modemcable053.173-58-74.mc.videotron.ca. [74.58.173.53]) by smtp.gmail.com with ESMTPSA id o19sm10869357qhb.31.2015.10.26.19.34.54 (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 26 Oct 2015 19:34:54 -0700 (PDT) Subject: Re: [PATCH c++ 12/12] ada-lang.h: Add cast in GROW_VECT To: Pedro Alves , gdb-patches@sourceware.org References: <1445831362-18789-1-git-send-email-simon.marchi@polymtl.ca> <1445831362-18789-2-git-send-email-simon.marchi@polymtl.ca> <562E59DF.9040407@redhat.com> From: Simon Marchi Message-ID: <562EE2CD.6050104@polymtl.ca> Date: Tue, 27 Oct 2015 09:54:00 -0000 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:38.0) Gecko/20100101 Thunderbird/38.3.0 MIME-Version: 1.0 In-Reply-To: <562E59DF.9040407@redhat.com> Content-Type: text/plain; charset=windows-1252 Content-Transfer-Encoding: 7bit X-SW-Source: 2015-10/txt/msg00595.txt.bz2 On 26/10/15 12:50 PM, Pedro Alves wrote: > 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 I thought about changing it for a proper VEC, but it's not really in the scope of the C++ changes. If I side-track on things like this, it will take an eternity! And I feel that at this moment, it would be a risk of introducing bugs without added value. Is it ok if I simply push your version that adds the (char *) in the macro? It seems like the most efficient fix given the situation.