Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions stl/inc/memory
Original file line number Diff line number Diff line change
Expand Up @@ -3611,6 +3611,7 @@ basic_ostream<_Elem, _Traits>& operator<<(basic_ostream<_Elem, _Traits>& _Out, c
}

// GARBAGE COLLECTION
#if _HAS_GARBAGE_COLLECTION_SUPPORT_DELETED_IN_CXX23
enum class pointer_safety { relaxed, preferred, strict };

inline void declare_reachable(void*) {}
Expand All @@ -3627,6 +3628,7 @@ inline void undeclare_no_pointers(char*, size_t) {}
inline pointer_safety get_pointer_safety() noexcept {
return pointer_safety::relaxed;
}
#endif // _HAS_GARBAGE_COLLECTION_SUPPORT_DELETED_IN_CXX23

// STRUCT TEMPLATE owner_less
template <class _Ty = void>
Expand Down
11 changes: 11 additions & 0 deletions stl/inc/yvals_core.h
Original file line number Diff line number Diff line change
Expand Up @@ -265,6 +265,7 @@
// P1682R3 to_underlying() For Enumerations
// P1989R2 Range Constructor For string_view
// P2166R1 Prohibiting basic_string And basic_string_view Construction From nullptr
// P2186R2 Removing Garbage Collection Support

// Parallel Algorithms Notes
// C++ allows an implementation to implement parallel algorithms as calls to the serial algorithms.
Expand Down Expand Up @@ -1124,6 +1125,16 @@
#define _HAS_STREAM_INSERTION_OPERATORS_DELETED_IN_CXX20 (_HAS_FEATURES_REMOVED_IN_CXX20)
#endif // _HAS_STREAM_INSERTION_OPERATORS_DELETED_IN_CXX20


#ifndef _HAS_FEATURES_REMOVED_IN_CXX23
#define _HAS_FEATURES_REMOVED_IN_CXX23 (!_HAS_CXX23)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is that correct. The default would be that those Features are removed.

Semantically this appears to be flipped

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same as https://github.com/microsoft/STL/blob/main/stl/inc/yvals_core.h#L1060-L1063

Yes. I think it's correct. It's name for users. If I as user define

#define _HAS_FEATURES_REMOVED_IN_CXX23  1

then include some standard hearders
and then all deleted features in c++23 are available for me.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yep, this is correct.

FYI: GitHub doesn't preview line-numbered links to files in main, because as main changes, the line numbers could be invalidated. However, if you press the y keyboard shortcut when viewing a file, the link will transform into a commit permalink, and then citing that in an issue/comment will be previewed. Here, https://github.com/microsoft/STL/blob/1866b848f0175c3361a916680a4318e7f0cc5482/stl/inc/yvals_core.h#L1060-L1063 will be previewed as:

STL/stl/inc/yvals_core.h

Lines 1060 to 1063 in 1866b84

// P0619R4 Removing C++17-Deprecated Features
#ifndef _HAS_FEATURES_REMOVED_IN_CXX20
#define _HAS_FEATURES_REMOVED_IN_CXX20 (!_HAS_CXX20)
#endif // _HAS_FEATURES_REMOVED_IN_CXX20

#endif // _HAS_FEATURES_REMOVED_IN_CXX23

// P2186R2 Removing Garbage Collection Support
#ifndef _HAS_GARBAGE_COLLECTION_SUPPORT_DELETED_IN_CXX23
#define _HAS_GARBAGE_COLLECTION_SUPPORT_DELETED_IN_CXX23 (_HAS_FEATURES_REMOVED_IN_CXX23)
#endif // _HAS_GARBAGE_COLLECTION_SUPPORT_DELETED_IN_CXX23

// LIBRARY FEATURE-TEST MACROS

// C++14
Expand Down
5 changes: 5 additions & 0 deletions tests/libcxx/expected_results.txt
Original file line number Diff line number Diff line change
Expand Up @@ -659,6 +659,11 @@ std/language.support/support.limits/support.limits.general/memory.version.pass.c
# should work
std/language.support/support.limits/support.limits.general/variant.version.pass.cpp FAIL

# libc++ doesn't implement P2186R2 Removing Garbage Collection Support
std/utilities/memory/util.dynamic.safety/get_pointer_safety.pass.cpp FAIL
std/utilities/memory/util.dynamic.safety/declare_no_pointers.pass.cpp FAIL
std/utilities/memory/util.dynamic.safety/declare_reachable.pass.cpp FAIL

# *** LIKELY STL BUGS ***
# Not yet analyzed, likely STL bugs. Assertions and other runtime failures.
std/numerics/rand/rand.dis/rand.dist.bern/rand.dist.bern.bin/eval_param.pass.cpp FAIL
Expand Down
5 changes: 5 additions & 0 deletions tests/libcxx/skipped_tests.txt
Original file line number Diff line number Diff line change
Expand Up @@ -659,6 +659,11 @@ language.support\support.limits\support.limits.general\memory.version.pass.cpp
# should work
language.support\support.limits\support.limits.general\variant.version.pass.cpp

# libc++ doesn't implement P2186R2 Removing Garbage Collection Support
utilities\memory\util.dynamic.safety\get_pointer_safety.pass.cpp
utilities\memory\util.dynamic.safety\declare_no_pointers.pass.cpp
utilities\memory\util.dynamic.safety\declare_reachable.pass.cpp

# *** LIKELY STL BUGS ***
# Not yet analyzed, likely STL bugs. Assertions and other runtime failures.
numerics\rand\rand.dis\rand.dist.bern\rand.dist.bern.bin\eval_param.pass.cpp
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -961,8 +961,10 @@ void memory_test() {
default_delete<int[]> dd1{default_delete<int[]>{}};
dd1(new int[5]);

#if _HAS_GARBAGE_COLLECTION_SUPPORT_DELETED_IN_CXX23
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same, I would have expected those to be there if they have not been deleted

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

int* int_ptr{};
undeclare_reachable(int_ptr);
#endif // _HAS_GARBAGE_COLLECTION_SUPPORT_DELETED_IN_CXX23

auto sptr = make_shared<int>(5);
auto wptr = weak_ptr<int>(sptr);
Expand Down
4 changes: 4 additions & 0 deletions tests/tr1/tests/memory/test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -199,6 +199,7 @@ void test_autoptr() { // test auto_ptr
CHECK_INT(cnt, 0);
}

#if _HAS_GARBAGE_COLLECTION_SUPPORT_DELETED_IN_CXX23
void test_gc() { // test garbage collection control
char x;
STD declare_reachable(&x);
Expand All @@ -209,11 +210,14 @@ void test_gc() { // test garbage collection control
|| (int) STD get_pointer_safety() == (int) STD pointer_safety::preferred
|| (int) STD get_pointer_safety() == (int) STD pointer_safety::strict);
}
#endif // _HAS_GARBAGE_COLLECTION_SUPPORT_DELETED_IN_CXX23

void test_main() { // test basic properties of memory definitions
test_alloc();
test_uninit();
test_tempbuf();
test_autoptr();
#if _HAS_GARBAGE_COLLECTION_SUPPORT_DELETED_IN_CXX23
test_gc();
#endif // _HAS_GARBAGE_COLLECTION_SUPPORT_DELETED_IN_CXX23
}