Skip to content

Conversation

frederick-vs-ja
Copy link
Contributor

And add some guaranteed cases (namely, for expected, optional, and variant) to is_implicit_lifetime.pass.cpp.

It's somehow unfortunate that pair and tuple are not guaranteed to propagate triviality of copy/move constructors, and MSVC STL fails to do so due to ABI compatibility. This affects the implicit-lifetime property.

… `_LIBCPP_VERSION`

And add some guaranteed cases to `is_implicit_lifetime.pass.cpp`.
@frederick-vs-ja frederick-vs-ja added the libc++ libc++ C++ Standard Library. Not GNU libstdc++. Not libc++abi. label Sep 25, 2025
@frederick-vs-ja frederick-vs-ja requested a review from a team as a code owner September 25, 2025 01:30
@llvmbot
Copy link
Member

llvmbot commented Sep 25, 2025

@llvm/pr-subscribers-libcxx

Author: A. Jiang (frederick-vs-ja)

Changes

And add some guaranteed cases (namely, for expected, optional, and variant) to is_implicit_lifetime.pass.cpp.

It's somehow unfortunate that pair and tuple are not guaranteed to propagate triviality of copy/move constructors, and MSVC STL fails to do so due to ABI compatibility. This affects the implicit-lifetime property.


Full diff: https://github.com/llvm/llvm-project/pull/160627.diff

1 Files Affected:

  • (modified) libcxx/test/std/utilities/meta/meta.unary/meta.unary.prop/is_implicit_lifetime.pass.cpp (+12)
diff --git a/libcxx/test/std/utilities/meta/meta.unary/meta.unary.prop/is_implicit_lifetime.pass.cpp b/libcxx/test/std/utilities/meta/meta.unary/meta.unary.prop/is_implicit_lifetime.pass.cpp
index a68f3f40e3647..6dcced8c4d000 100644
--- a/libcxx/test/std/utilities/meta/meta.unary/meta.unary.prop/is_implicit_lifetime.pass.cpp
+++ b/libcxx/test/std/utilities/meta/meta.unary/meta.unary.prop/is_implicit_lifetime.pass.cpp
@@ -17,9 +17,12 @@
 
 #include <cassert>
 #include <cstddef>
+#include <expected>
+#include <optional>
 #include <tuple>
 #include <type_traits>
 #include <utility>
+#include <variant>
 
 #include "test_macros.h"
 #include "type_algorithms.h"
@@ -216,8 +219,17 @@ constexpr bool test() {
 
   // C++ standard library types
 
+  // These types are guaranteed to be implicit-lifetime.
+  test_is_implicit_lifetime<std::expected<int, float>>();
+  test_is_implicit_lifetime<std::optional<float>>();
+  test_is_implicit_lifetime<std::variant<float, int>>();
+
+#ifdef _LIBCPP_VERSION
+  // These types should be implicit-lifetime, but they are not guaranteed to be so.
+  // Especially, MSVC STL has not made them implicit-lifetime yet. See https://github.com/microsoft/STL/issues/5667.
   test_is_implicit_lifetime<std::pair<int, float>>();
   test_is_implicit_lifetime<std::tuple<int, float>>();
+#endif
 
   // Standard C23 types
 

@frederick-vs-ja
Copy link
Contributor Author

Merging as CI failures are unrelated.

@frederick-vs-ja frederick-vs-ja merged commit f6fc5e8 into llvm:main Sep 26, 2025
75 of 78 checks passed
@frederick-vs-ja frederick-vs-ja deleted the libcxx-test-implicit-lifetime-std branch September 26, 2025 10:08
mahesh-attarde pushed a commit to mahesh-attarde/llvm-project that referenced this pull request Oct 3, 2025
… `_LIBCPP_VERSION` (llvm#160627)

And add some guaranteed cases (namely, for `expected`, `optional`, and
`variant`) to `is_implicit_lifetime.pass.cpp`.

It's somehow unfortunate that `pair` and `tuple` are not guaranteed to
propagate triviality of copy/move constructors, and MSVC STL fails to do
so due to ABI compatibility. This affects the implicit-lifetime
property.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
libc++ libc++ C++ Standard Library. Not GNU libstdc++. Not libc++abi. test-suite
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants