This is the mail archive of the libstdc++@gcc.gnu.org mailing list for the libstdc++ 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]

Re: Possible bug in shared_ptr(unique_ptr) constructor?


2013/10/7 Jonathan Wakely <jwakely.gcc@gmail.com>:
> And here's a suggested patch to fix it:
>
> +      template<typename _Sp, typename _Up>
> +       static _Sp_counted_base<_Lp>*
> +       _S_do_create_from_up(_Up&& __r)
> +       {
> +         using _Alloc = std::allocator<_Sp>;
> +         using _ATr = std::allocator_traits<_Alloc>;
> +         _Alloc __a;
> +         auto __ptr = _ATr::allocate(__a, 1);
> +         _ATr::construct(__a, __ptr, __r.get(), __r.get_deleter());
> +         return __ptr;
>         }

Question: Is it impossible that the construction could throw an
exception here or why is there no need to RAII-protect the
intermediate __ptr value?

- Daniel


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