Skip to content

Commit 2eadc6d

Browse files
committed
Address review comments.
1 parent 712a416 commit 2eadc6d

File tree

3 files changed

+30
-8
lines changed

3 files changed

+30
-8
lines changed

libcxx/include/__memory/unique_ptr.h

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -53,10 +53,7 @@ _LIBCPP_PUSH_MACROS
5353
_LIBCPP_BEGIN_NAMESPACE_STD
5454

5555
#ifndef _LIBCPP_CXX03_LANG
56-
// Dereferencing _Ptr directly in noexcept fails for a void pointer.
57-
// This is not SFINAE-ed away leading to a hard error.
58-
// The issue was originally triggered by
59-
// test/std/utilities/memory/unique.ptr/iterator_concept_conformance.compile.pass.cpp
56+
6057
template <class _Ptr>
6158
struct __is_noexcept_deref_or_void {
6259
static constexpr bool value = noexcept(*std::declval<_Ptr>());
@@ -269,10 +266,7 @@ class _LIBCPP_UNIQUE_PTR_TRIVIAL_ABI _LIBCPP_TEMPLATE_VIS unique_ptr {
269266
}
270267

271268
_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX23 __add_lvalue_reference_t<_Tp> operator*() const
272-
#ifndef _LIBCPP_CXX03_LANG
273-
noexcept(__is_noexcept_deref_or_void<pointer>::value)
274-
#endif
275-
{
269+
_NOEXCEPT_(__is_noexcept_deref_or_void<pointer>::value) {
276270
return *__ptr_.first();
277271
}
278272
_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX23 pointer operator->() const _NOEXCEPT { return __ptr_.first(); }
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
//===----------------------------------------------------------------------===//
2+
//
3+
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4+
// See https://llvm.org/LICENSE.txt for license information.
5+
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6+
//
7+
//===----------------------------------------------------------------------===//
8+
9+
// UNSUPPORTED: c++03
10+
11+
// unique_ptr
12+
13+
// add_lvalue_reference_t<T> operator*() const noexcept(noexcept(*declval<pointer>()));
14+
15+
// Dereferencing pointer directly in noexcept fails for a void pointer. This
16+
// is not SFINAE-ed away leading to a hard error. The issue was originally
17+
// triggered by
18+
// test/std/utilities/memory/unique.ptr/iterator_concept_conformance.compile.pass.cpp
19+
//
20+
// This test validates whether the code compiles.
21+
22+
#include <memory>
23+
24+
extern const std::unique_ptr<void> p;
25+
void f() { [[maybe_unused]] bool b = noexcept(p.operator*()); }

libcxx/test/std/utilities/smartptr/unique.ptr/unique.ptr.class/unique.ptr.observers/dereference.single.pass.cpp

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,9 @@ struct Deleter {
3232

3333
TEST_CONSTEXPR_CXX23 bool test() {
3434
ASSERT_NOEXCEPT(*(std::unique_ptr<void>{}));
35+
#if TEST_STD_VER >= 11
36+
static_assert(noexcept(*std::declval<std::unique_ptr<void>>()), "");
37+
#endif
3538
{
3639
std::unique_ptr<int> p(new int(3));
3740
assert(*p == 3);

0 commit comments

Comments
 (0)