This is the mail archive of the gcc-bugs@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[Bug libstdc++/78595] Unnecessary copies in _Rb_tree


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.

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]