This is the mail archive of the
gdb-patches@sourceware.org
mailing list for the GDB project.
Re: [PATCH 03/10] Make target_desc::features an std::vector
- From: Simon Marchi <simon dot marchi at ericsson dot com>
- To: Yao Qi <qiyaoltc at gmail dot com>
- Cc: <gdb-patches at sourceware dot org>, Simon Marchi <simon dot marchi at polymtl dot ca>
- Date: Thu, 2 Nov 2017 09:20:13 -0400
- Subject: Re: [PATCH 03/10] Make target_desc::features an std::vector
- Authentication-results: sourceware.org; auth=none
- Authentication-results: spf=none (sender IP is ) smtp.mailfrom=simon dot marchi at ericsson dot com;
- References: <1509414120-14659-1-git-send-email-simon.marchi@ericsson.com> <1509414120-14659-4-git-send-email-simon.marchi@ericsson.com> <868tfpxc3l.fsf@gmail.com>
- Spamdiagnosticmetadata: NSPM
- Spamdiagnosticoutput: 1:99
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