From: Jonathan Wakely <jwakely@redhat.com>
To: Patrick Palka <ppalka@redhat.com>
Cc: libstdc++@gcc.gnu.org, gcc-patches@gcc.gnu.org
Subject: Re: [PATCH] libstdc++: Fix the default constructor of ranges::__detail::__box
Date: Fri, 30 Oct 2020 10:33:29 +0000 [thread overview]
Message-ID: <20201030103329.GG503596@redhat.com> (raw)
In-Reply-To: <5b86a40-d458-26cc-4f5e-9191185eefab@idea>
On 29/10/20 19:48 -0400, Patrick Palka via Libstdc++ wrote:
>On Thu, 29 Oct 2020, Patrick Palka wrote:
>
>> The class template semiregular-box<T> of [range.semi.wrap] is specified
>> to value-initialize the underlying object whenever its type is default-
>> initializable. Our primary template for __detail::__box respects this
>> requirement, but the recently added partial specialization (for types
>> which are already semiregular) does not.
>>
>> This patch fixes this issue, and additionally makes the in place
>> constructor explicit (as in the primary template).
>>
>> Tested on x86_64-pc-linux-gnu, does this look OK for trunk?
>>
>> libstdc++-v3/ChangeLog:
>>
>> * include/std/ranges (__detail::__box): For the partial
>> specialization for types that are already semiregular,
>> make the default constructor value-initialize the underlying
>> object instead of default-initializing it. Make the
>> corresponding in place constructor explicit.
>> * testsuite/std/ranges/detail/semiregular_box.cc: New test.
>> ---
>> libstdc++-v3/include/std/ranges | 4 +--
>> .../std/ranges/detail/semiregular_box.cc | 33 +++++++++++++++++++
>> 2 files changed, 35 insertions(+), 2 deletions(-)
>> create mode 100644 libstdc++-v3/testsuite/std/ranges/detail/semiregular_box.cc
>>
>> diff --git a/libstdc++-v3/include/std/ranges b/libstdc++-v3/include/std/ranges
>> index df02b03cada..59aac326309 100644
>> --- a/libstdc++-v3/include/std/ranges
>> +++ b/libstdc++-v3/include/std/ranges
>> @@ -141,7 +141,7 @@ namespace ranges
>> struct __box<_Tp>
>> {
>> private:
>> - [[no_unique_address]] _Tp _M_value;
>> + [[no_unique_address]] _Tp _M_value = {};
>
>It would be more consistent with the rest of the header to do = _Tp()
>instead:
OK, thanks.
prev parent reply other threads:[~2020-10-30 10:33 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-10-29 23:11 Patrick Palka
2020-10-29 23:48 ` Patrick Palka
2020-10-30 10:33 ` Jonathan Wakely [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20201030103329.GG503596@redhat.com \
--to=jwakely@redhat.com \
--cc=gcc-patches@gcc.gnu.org \
--cc=libstdc++@gcc.gnu.org \
--cc=ppalka@redhat.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).