[libcxx-commits] [PATCH] D102119: [libcxx][optional] adds missing constexpr operations

Christopher Di Bella via Phabricator via libcxx-commits libcxx-commits at lists.llvm.org
Thu May 20 10:55:20 PDT 2021


cjdb added inline comments.


================
Comment at: libcxx/include/optional:72
   // 23.6.9, specialized algorithms
-  template <class T> void swap(optional<T>&, optional<T>&) noexcept(see below );
+  template <class T> void swap(optional<T>&, optional<T>&) noexcept(see below ); // constexpr in C++20
   template <class T> constexpr optional<see below > make_optional(T&&);
----------------
ldionne wrote:
> Should be `// constexpr in C++2b (in C++20 as an extension)` or something along those lines, just to acknowledge that we're supporting that as an extension.
Is it really an extension if LWG are recommending we backport it to C++20 as a "fix"?


================
Comment at: libcxx/test/std/utilities/optional/optional.object/optional.object.assign/emplace.pass.cpp:233
         test_one_arg<const T>();
+#if TEST_STD_VER >= 20 && !defined(TEST_COMPILER_GCC)
+        static_assert(test_one_arg<T>());
----------------
ldionne wrote:
> This should be:
> 
> ```
> #if TEST_STD_VER > 20 || (TEST_STD_VER >= 20 && defined(_LIBCPP_VER))
> ```
> 
> Basically, test it in C++2b, or in C++20 but only when testing libc++, since it is out own extension. Otherwise, a conforming implementation will fail the test suite in C++20 mode because they don't implement `constexpr` for `std::optional`. This applies everywhere.
> 
> Also, what's the deal with GCC? If it fails those tests, we should first report the issue to GCC and then use some `XFAIL` markup to disable it instead.
> Also, what's the deal with GCC? If it fails those tests, we should first report the issue to GCC and then use some `XFAIL` markup to disable it instead.

GCC 10 doesn't like our constexpr `construct_at` (GCC 11 is okay with it). I wasn't comfortable saying GCC couldn't test this file //at all// given it still works outside of constant expressions.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D102119/new/

https://reviews.llvm.org/D102119



More information about the libcxx-commits mailing list