Skip to content

Commit 9694e9c

Browse files
committed
Fix gcc constexpr evaluation failure
1 parent 79e0e29 commit 9694e9c

File tree

6 files changed

+18
-28
lines changed

6 files changed

+18
-28
lines changed

libcxx/include/__memory/pointer_traits.h

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -302,14 +302,6 @@ concept __resettable_smart_pointer_with_args = requires(_Smart __s, _Pointer __p
302302

303303
#endif
304304

305-
template <class _PtrTo, class _PtrFrom>
306-
_LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI _PtrTo __static_fancy_pointer_cast(const _PtrFrom& __p) {
307-
using __ptr_traits = pointer_traits<_PtrTo>;
308-
using __element_type = typename __ptr_traits::element_type;
309-
return __p ? __ptr_traits::pointer_to(*static_cast<__element_type*>(std::addressof(*__p)))
310-
: static_cast<_PtrTo>(nullptr);
311-
}
312-
313305
_LIBCPP_END_NAMESPACE_STD
314306

315307
_LIBCPP_POP_MACROS

libcxx/include/list

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -344,7 +344,7 @@ public:
344344

345345
_LIBCPP_CONSTEXPR_SINCE_CXX26 _LIBCPP_HIDE_FROM_ABI __base_pointer __as_link() {
346346
return pointer_traits<__base_pointer>::pointer_to(
347-
*static_cast<typename pointer_traits<__base_pointer>::element_type*>(this));
347+
*static_cast<typename pointer_traits<__base_pointer>::element_type*>(std::addressof(*this)));
348348
}
349349
};
350350

libcxx/test/std/containers/sequences/list/list.capacity/resize_size.pass.cpp

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,6 @@
1212

1313
#include <list>
1414
#include <cassert>
15-
#include <type_traits>
1615

1716
#include "test_macros.h"
1817
#include "DefaultOnly.h"
@@ -35,7 +34,7 @@ TEST_CONSTEXPR_CXX26 bool test() {
3534
assert(l.back() == 0);
3635
}
3736
#if TEST_STD_VER >= 11
38-
if (!std::is_constant_evaluated()) {
37+
if (!TEST_IS_CONSTANT_EVALUATED) {
3938
{
4039
std::list<DefaultOnly> l(10);
4140
l.resize(5);

libcxx/test/std/containers/sequences/list/list.cons/input_iterator.pass.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -174,7 +174,7 @@ TEST_CONSTEXPR_CXX26 void test_emplacable_concept_with_alloc() {
174174
#endif
175175
}
176176

177-
TEST_CONSTEXPR_CXX26 void test_ctor_under_alloc() {
177+
void test_ctor_under_alloc() {
178178
#if TEST_STD_VER >= 11
179179
int arr1[] = {42};
180180
int arr2[] = {1, 101, 42};
@@ -205,7 +205,7 @@ TEST_CONSTEXPR_CXX26 void test_ctor_under_alloc() {
205205
#endif
206206
}
207207

208-
TEST_CONSTEXPR_CXX26 void test_ctor_under_alloc_with_alloc() {
208+
void test_ctor_under_alloc_with_alloc() {
209209
#if TEST_STD_VER >= 11
210210
int arr1[] = {42};
211211
int arr2[] = {1, 101, 42};

libcxx/test/std/containers/sequences/list/list.cons/size_type.pass.cpp

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,6 @@
1313
#include <list>
1414
#include <cassert>
1515
#include <cstddef>
16-
#include <type_traits>
1716

1817
#include "test_macros.h"
1918
#include "DefaultOnly.h"
@@ -88,7 +87,7 @@ TEST_CONSTEXPR_CXX26 bool test() {
8887
assert(*i == 0);
8988
}
9089

91-
if (!std::is_constant_evaluated()) {
90+
if (!TEST_IS_CONSTANT_EVALUATED) {
9291
{
9392
std::list<DefaultOnly> l(3);
9493
assert(l.size() == 3);

libcxx/test/support/counting_predicates.h

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -28,8 +28,8 @@ struct unary_counting_predicate {
2828
++count_;
2929
return p_(a);
3030
}
31-
TEST_CONSTEXPR std::size_t count() const { return count_; }
32-
TEST_CONSTEXPR void reset() { count_ = 0; }
31+
TEST_CONSTEXPR_CXX14 std::size_t count() const { return count_; }
32+
TEST_CONSTEXPR_CXX14 void reset() { count_ = 0; }
3333

3434
private:
3535
Predicate p_;
@@ -43,17 +43,17 @@ struct binary_counting_predicate {
4343
typedef Arg2 second_argument_type;
4444
typedef bool result_type;
4545

46-
TEST_CONSTEXPR binary_counting_predicate(Predicate p) : p_(p), count_(0) {}
47-
TEST_CONSTEXPR_CXX14 bool operator()(const Arg1& a1, const Arg2& a2) const {
48-
++count_;
49-
return p_(a1, a2);
50-
}
51-
TEST_CONSTEXPR std::size_t count() const { return count_; }
52-
TEST_CONSTEXPR_CXX14 void reset() { count_ = 0; }
53-
54-
private:
55-
Predicate p_;
56-
mutable std::size_t count_;
46+
TEST_CONSTEXPR binary_counting_predicate(Predicate p) : p_(p), count_(0) {}
47+
TEST_CONSTEXPR_CXX14 bool operator()(const Arg1& a1, const Arg2& a2) const {
48+
++count_;
49+
return p_(a1, a2);
50+
}
51+
TEST_CONSTEXPR std::size_t count() const { return count_; }
52+
TEST_CONSTEXPR_CXX14 void reset() { count_ = 0; }
53+
54+
private:
55+
Predicate p_;
56+
mutable std::size_t count_;
5757
};
5858

5959
#if TEST_STD_VER > 14

0 commit comments

Comments
 (0)