+2016-10-19 Jonathan Wakely <jwakely@redhat.com>
+
+ PR libstdc++/77990
+ * include/bits/unique_ptr.h (unique_ptr::unique_ptr(pointer)): Set
+ pointer member after value-initialization of tuple.
+ * testsuite/20_util/unique_ptr/assign/48635_neg.cc: Adjust dg-errors.
+ * testsuite/20_util/unique_ptr/cons/77990.cc: New test.
+
2016-10-17 Jonathan Wakely <jwakely@redhat.com>
Backport from mainline:
*/
explicit
unique_ptr(pointer __p) noexcept
- : _M_t(__p, deleter_type())
- { static_assert(!is_pointer<deleter_type>::value,
- "constructed with null function pointer deleter"); }
+ : _M_t()
+ {
+ std::get<0>(_M_t) = __p;
+ static_assert(!is_pointer<deleter_type>::value,
+ "constructed with null function pointer deleter");
+ }
/** Takes ownership of a pointer.
*
std::unique_ptr<int, B&> ub(nullptr, b);
std::unique_ptr<int, D&> ud(nullptr, d);
ub = std::move(ud);
-// { dg-error "use of deleted function" "" { target *-*-* } 272 }
+// { dg-error "use of deleted function" "" { target *-*-* } 275 }
std::unique_ptr<int[], B&> uba(nullptr, b);
std::unique_ptr<int[], D&> uda(nullptr, d);
uba = std::move(uda);
-// { dg-error "use of deleted function" "" { target *-*-* } 517 }
+// { dg-error "use of deleted function" "" { target *-*-* } 520 }
}
--- /dev/null
+// Copyright (C) 2016 Free Software Foundation, Inc.
+//
+// This file is part of the GNU ISO C++ Library. This library is free
+// software; you can redistribute it and/or modify it under the
+// terms of the GNU General Public License as published by the
+// Free Software Foundation; either version 3, or (at your option)
+// any later version.
+
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+
+// You should have received a copy of the GNU General Public License along
+// with this library; see the file COPYING3. If not see
+// <http://www.gnu.org/licenses/>.
+
+// { dg-options "-std=gnu++11" }
+// { dg-do compile }
+
+#include <memory>
+
+struct D {
+ D() = default;
+ D(const D&) = delete;
+ void operator()(int*);
+};
+std::unique_ptr<int, D> p((int*)nullptr); // PR libstdc++/77990