From: Jonathan Wakely <jwakely@redhat.com>
To: "François Dumont" <frs.dumont@gmail.com>
Cc: libstdc++@gcc.gnu.org, gcc-patches <gcc-patches@gcc.gnu.org>
Subject: Re: [PATCH] 77864 Fix noexcept conditions for map/set default constructors
Date: Sun, 09 Oct 2016 15:38:00 -0000 [thread overview]
Message-ID: <20161009153839.GC25380@redhat.com> (raw)
In-Reply-To: <20161009151451.GB25380@redhat.com>
On 09/10/16 16:14 +0100, Jonathan Wakely wrote:
>On 08/10/16 22:55 +0200, François Dumont wrote:
>>On 06/10/2016 23:34, Jonathan Wakely wrote:
>>>On 06/10/16 22:17 +0200, François Dumont wrote:
>>>>Another approach is to rely on existing compiler ability to
>>>>compute conditional noexcept when defaulting implementations.
>>>>This is what I have done in this patch.
>>>>
>>>>The new default constructor on _Rb_tree_node_base is not a
>>>>problem as it is not used to build _Rb_tree_node.
>>>
>>>Why not?
>>
>>_Rb_tree_node_base is used in 2 context. As member of _Rb_tree_impl
>>in which case we need the new default constructor. And also as base
>>class of _Rb_tree_node which is never constructed. Nodes are being
>>allocated and then associated value is being constructed through the
>>allocator, the node default constructor itself is never invoked.
>
>In C++03 mode that is true, but it's only valid because the type is
>trivially-constructible. If the type requires "non-vacuous
>initialization" then it's not valid to allocate memory for it and
>start using it without invoking a constructor. If you add a
>non-trivial constructor then we can't do that any more.
In fact that code is highly questionable, because the element member
makes the node require non-trivial initialization. We rely on the base
being trivially-constructible, and the element being constructed by
the allocator, and assume that it's OK to then treat that memory as a
node. In fact only its base class and member have been constructed,
not the node itself. The C++11 version (using an aligned buffer) is
correct. But I'd prefer not to make the C++98 version worse.
next prev parent reply other threads:[~2016-10-09 15:38 UTC|newest]
Thread overview: 16+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-10-05 11:56 Jonathan Wakely
2016-10-05 12:11 ` Marc Glisse
2016-10-05 12:13 ` Jonathan Wakely
2016-10-06 20:17 ` François Dumont
2016-10-06 21:34 ` Jonathan Wakely
2016-10-08 20:55 ` François Dumont
2016-10-09 15:14 ` Jonathan Wakely
2016-10-09 15:38 ` Jonathan Wakely [this message]
2016-10-10 19:24 ` François Dumont
[not found] ` <CAPQZVxvFJb4gwj2cpxvTPZgBtiyZyviqz0iLhW4sAY6rSrjn6w@mail.gmail.com>
2016-10-10 21:01 ` Tim Song
2016-10-12 20:36 ` François Dumont
2016-10-12 21:26 ` Tim Song
2016-10-23 13:54 ` François Dumont
2016-10-24 11:03 ` Jonathan Wakely
2016-10-25 19:55 ` François Dumont
2016-10-26 8:22 ` Jonathan Wakely
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=20161009153839.GC25380@redhat.com \
--to=jwakely@redhat.com \
--cc=frs.dumont@gmail.com \
--cc=gcc-patches@gcc.gnu.org \
--cc=libstdc++@gcc.gnu.org \
/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).