This is the mail archive of the
gdb-patches@sourceware.org
mailing list for the GDB project.
Re: [PATCH] Introduce gdb::byte_vector, add allocator that default-initializes
- From: Pedro Alves <palves at redhat dot com>
- To: Simon Marchi <simon dot marchi at ericsson dot com>, Simon Marchi <simon dot marchi at polymtl dot ca>
- Cc: gdb-patches at sourceware dot org
- Date: Wed, 13 Sep 2017 14:30:33 +0100
- Subject: Re: [PATCH] Introduce gdb::byte_vector, add allocator that default-initializes
- Authentication-results: sourceware.org; auth=none
- Authentication-results: ext-mx04.extmail.prod.ext.phx2.redhat.com; dmarc=none (p=none dis=none) header.from=redhat.com
- Authentication-results: ext-mx04.extmail.prod.ext.phx2.redhat.com; spf=fail smtp.mailfrom=palves at redhat dot com
- Dmarc-filter: OpenDMARC Filter v1.3.2 mx1.redhat.com 0126D7EA85
- References: <1497287225-16542-1-git-send-email-palves@redhat.com> <09d8de02f155c73bb3d04c9589589327@polymtl.ca> <583dd599-bcb3-d729-9b79-4dd9ccb26121@redhat.com> <975b9c0aac917b6954d9dffd0438de82@polymtl.ca> <78076de1-a317-3e38-8529-63824943e3af@redhat.com> <8d187d70-b45a-7336-190b-cb8e7ad47b4b@ericsson.com>
On 09/09/2017 08:11 PM, Simon Marchi wrote:
> On 2017-06-14 12:21 PM, Pedro Alves wrote:
>> On 06/14/2017 09:39 AM, Simon Marchi wrote:
>>
>>> Thanks for the detailed explanation. It's all very logical, but it's
>>> also full of small details essential to really understand what's happening.
>>
>> Yeah... As custom with "library" code, thankfully uses of the types
>> can remain oblivious to how the types work under the hood.
>>
>> I've pushed the patch in now, with the trivial adjustments to both
>> dwarf2loc.c, after Andreas' series, and to make the new int128_t printing
>> code use gdb::byte_vector.
>
> Hi Pedro,
>
> I am looking at Tom's recent patch that uses def_vector, and I am wondering
> if there should be a check somewhere to make sure we don't use the
> default_init_allocator with non-default-constructible types. Let's say we use
> def_vector with a trivial type, and then we later decide to make that type
> non-trivial by defining a constructor. It looks like it would still build,
> but I suppose we shouldn't use that type in a def_vector (for the same reason
> that we shouldn't allocate it with malloc). It could easily go unnoticed for
> a while.
It'd be unnecessary to use def_vector, but also harmless.
value vs default initialization only makes a difference for types _without_
constructors. Default initialization of a type with a default
constructor also runs the default constructor, just like value
initialization.
Thanks,
Pedro Alves