[libcxx-commits] [libcxx] 41c11fa - [libc++][test] Remove non-functional `constexpr` in three-way comparison test for `variant` (#222837)

via libcxx-commits libcxx-commits at lists.llvm.org
Fri Sep 11 03:03:39 PDT 2026


Author: A. Jiang
Date: 2026-09-11T18:03:33+08:00
New Revision: 41c11fa5c016886d5858a1aba03a5980688ad5a1

URL: https://github.com/llvm/llvm-project/commit/41c11fa5c016886d5858a1aba03a5980688ad5a1
DIFF: https://github.com/llvm/llvm-project/commit/41c11fa5c016886d5858a1aba03a5980688ad5a1.diff

LOG: [libc++][test] Remove non-functional `constexpr` in three-way comparison test for `variant` (#222837)

When we are just testing SFINAE and do not provide definitions for these
comparison operators, or make them deleted, it is unhelpful to mark them
`constexpr`.

If the implementation uses `std::compare_three_way`, which uses deduced
return type in its `operator()`, in the `operator<=>` for `variant`,
more things in the function body would be instantiated and detected. As
a result, the `-Wundefined-inline` warning or something similar could be
raised. Currently, MSVC STL is doing so.

Added: 
    

Modified: 
    libcxx/test/std/utilities/variant/variant.relops/three_way.pass.cpp

Removed: 
    


################################################################################
diff  --git a/libcxx/test/std/utilities/variant/variant.relops/three_way.pass.cpp b/libcxx/test/std/utilities/variant/variant.relops/three_way.pass.cpp
index c235967abcc9d..181d58b741dc6 100644
--- a/libcxx/test/std/utilities/variant/variant.relops/three_way.pass.cpp
+++ b/libcxx/test/std/utilities/variant/variant.relops/three_way.pass.cpp
@@ -148,18 +148,18 @@ concept has_three_way_op = requires (T& t, U& u) { t <=> u; };
 using std::three_way_comparable;
 
 struct HasSimpleOrdering {
-  constexpr bool operator==(const HasSimpleOrdering&) const;
-  constexpr bool operator<(const HasSimpleOrdering&) const;
+  bool operator==(const HasSimpleOrdering&) const;
+  bool operator<(const HasSimpleOrdering&) const;
 };
 
 struct HasOnlySpaceship {
-  constexpr bool operator==(const HasOnlySpaceship&) const = delete;
-  constexpr std::weak_ordering operator<=>(const HasOnlySpaceship&) const;
+  bool operator==(const HasOnlySpaceship&) const = delete;
+  std::weak_ordering operator<=>(const HasOnlySpaceship&) const;
 };
 
 struct HasFullOrdering {
-  constexpr bool operator==(const HasFullOrdering&) const;
-  constexpr std::weak_ordering operator<=>(const HasFullOrdering&) const;
+  bool operator==(const HasFullOrdering&) const;
+  std::weak_ordering operator<=>(const HasFullOrdering&) const;
 };
 
 // operator<=> must resolve the return types of all its union types'


        


More information about the libcxx-commits mailing list