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 03/10] Make target_desc::features an std::vector


On 2017-11-02 05:29 AM, Yao Qi wrote:
> Simon Marchi <simon.marchi@ericsson.com> writes:
> 
> Patch is good to me, two comments below,
> 
>> +typedef std::unique_ptr<tdesc_feature> tdesc_feature_up;
>>  
>>  /* A target description.  */
>>  
>> @@ -393,17 +394,7 @@ struct target_desc : tdesc_element
>>    target_desc ()
>>    {}
>>  
>> -  virtual ~target_desc ()
>> -  {
>> -    struct tdesc_feature *feature;
>> -    int ix;
>> -
>> -    for (ix = 0;
>> -	 VEC_iterate (tdesc_feature_p, features, ix, feature);
>> -	 ix++)
>> -      delete feature;
>> -    VEC_free (tdesc_feature_p, features);
>> -  }
>> +  virtual ~target_desc () = default;
>>  
> 
> Can't we remove this line and use default (compiler generated)
> dtor?

If I do, I get the following error:

/home/emaisin/src/binutils-gdb/gdb/target-descriptions.c: In function ‘void free_target_description(void*)’:
/home/emaisin/src/binutils-gdb/gdb/target-descriptions.c:1714:10: error: deleting object of polymorphic class type ‘target_desc’ which has non-virtual destructor might cause undefined behaviour [-Werror=delete-non-virtual-dtor]
Makefile:1929: recipe for target 'target-descriptions.o' failed
   delete target_desc;
          ^
>>    target_desc (const target_desc &) = delete;
>>    void operator= (const target_desc &) = delete;
>> @@ -422,17 +413,13 @@ struct target_desc : tdesc_element
>>    std::vector<property> properties;
>>  
>>    /* The features associated with this target.  */
>> -  VEC(tdesc_feature_p) *features = NULL;
>> +  std::vector<std::unique_ptr<tdesc_feature>> features;
>>  
> 
> std::vector<tdesc_feature_up> features;
> 
> shorten the code.

Yes, I added the typedef later and forgot that instance.

Thanks, I fixed that one locally.

Simon


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