This is the mail archive of the
libstdc++@gcc.gnu.org
mailing list for the libstdc++ project.
Re: Default std::vector<bool> default and move constructor
- From: Jonathan Wakely <jwakely at redhat dot com>
- To: François Dumont <frs dot dumont at gmail dot com>
- Cc: "libstdc++ at gcc dot gnu dot org" <libstdc++ at gcc dot gnu dot org>, gcc-patches <gcc-patches at gcc dot gnu dot org>
- Date: Fri, 2 Jun 2017 11:27:18 +0100
- Subject: Re: Default std::vector<bool> default and move constructor
- Authentication-results: sourceware.org; auth=none
- Authentication-results: ext-mx10.extmail.prod.ext.phx2.redhat.com; dmarc=none (p=none dis=none) header.from=redhat.com
- Authentication-results: ext-mx10.extmail.prod.ext.phx2.redhat.com; spf=pass smtp.mailfrom=jwakely at redhat dot com
- Dkim-filter: OpenDKIM Filter v2.11.0 mx1.redhat.com 6CCCD142A78
- Dmarc-filter: OpenDMARC Filter v1.3.2 mx1.redhat.com 6CCCD142A78
- References: <cda87f91-d9fd-692b-f60e-dcc92728f02e@gmail.com> <20170525162816.GD12306@redhat.com> <ecc75c47-7a8e-2b91-7ef0-8cf2e1a09815@gmail.com> <20170527111401.GH12306@redhat.com> <b580bfe8-adef-1926-7b2b-2a6a6ca478cf@gmail.com> <4fcb496e-08ed-85ef-0470-e4f5b0d816ca@gmail.com> <20170531103454.GL12306@redhat.com> <164fb25b-dedc-21f4-9305-f68c47fa58df@gmail.com> <20170601133402.GU12306@redhat.com> <f5c82f7f-a075-641f-7fc4-11144a023949@gmail.com>
On 01/06/17 22:49 +0200, François Dumont wrote:
On 01/06/2017 15:34, Jonathan Wakely wrote:
On 31/05/17 22:28 +0200, François Dumont wrote:
Unless I made a mistake it revealed that restoring explicit call
to _Bit_alloc_type() in default constructor was not enough. G++
doesn't transform it into a value-init if needed. I don't know if
it is a compiler bug but I had to do just like presented in the
Standard to achieve the expected behavior.
That really shouldn't be necessary (see blow).
This value-init is specific to post-C++11 right ? Maybe I could
remove the useless explicit call to _Bit_alloc_type() in pre-C++11
mode ?
No, because C++03 also requires the allocator to be value-initialized.
Ok so I'll try to make the test C++03 compatible.
That would require a much more complicated allocator, so I don't think
it's too important.
If you define the constructor like:
_Bvector_impl()
_GLIBCXX_NOEXCEPT_IF( noexcept(_Bit_alloc_type()) )
: _Bit_alloc_type()
{ }
then it will do the same thing for C++03 as for later versions, so
testing for C++11 only should be good enough.