This is the mail archive of the gdb-patches@sourceware.org mailing list for the GDB project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: [PATCH c++ 12/12] ada-lang.h: Add cast in GROW_VECT


On 10/27/2015 02:34 AM, Simon Marchi wrote:
> On 26/10/15 12:50 PM, Pedro Alves wrote:

>> 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".

> 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.

It's certainly fine with me.

Thanks,
Pedro Alves


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]