This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
[Bug libstdc++/78595] Unnecessary copies in _Rb_tree
- From: "redi at gcc dot gnu.org" <gcc-bugzilla at gcc dot gnu dot org>
- To: gcc-bugs at gcc dot gnu dot org
- Date: Fri, 02 Dec 2016 14:57:53 +0000
- Subject: [Bug libstdc++/78595] Unnecessary copies in _Rb_tree
- Auto-submitted: auto-generated
- References: <bug-78595-4@http.gcc.gnu.org/bugzilla/>
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=78595
--- Comment #6 from Jonathan Wakely <redi at gcc dot gnu.org> ---
(In reply to Jonathan Wakely from comment #0)
> This prints "conv" twice, because we create a temporary to get the key here:
>
> pair<_Base_ptr, _Base_ptr> __res
> = _M_get_insert_unique_pos(_KeyOfValue()(__v));
This is extra-broken, because the temporary that gets implicitly created could
fail for at least these reasons:
- the relevant constructor of value_type is explicit
- there is no relevant constructor, because it expects an allocator (we would
need to use the _Temporary_value helper type from <bits/stl_vector.h> there)
Even if the implicit conversion works, the key of that temporary might not be
the same as the key that would result from constructing the value_type with an
allocator.
Here be dragons. With guns. And they're angry.