[libcxx-commits] [PATCH] D106916: [libc++] Handle arrays in std::destroy_at

Louis Dionne via Phabricator via libcxx-commits libcxx-commits at lists.llvm.org
Tue Jul 27 14:17:53 PDT 2021


ldionne added inline comments.


================
Comment at: libcxx/test/std/utilities/memory/specialized.algorithms/specialized.destroy/destroy.pass.cpp:81
+    //       in a constexpr context.
+    if (std::is_constant_evaluated())
+        return true;
----------------
This is pretty lame, but I couldn't find a way to test array support in constexpr mode before `std::construct_at` has support for arrays.

The problem is that we run into this kind of issue:

```
libcxx/test/std/utilities/memory/specialized.algorithms/specialized.destroy/destroy.pass.cpp:132:19: error: static_assert expression is not an integral constant expression
    static_assert(test());
                  ^~~~~~
build/default/include/c++/v1/__memory/construct_at.h:40:12: note: construction of subobject of object outside its lifetime is not allowed in a constant expression
    return ::new ((void*)__location) _Tp(_VSTD::forward<_Args>(__args)...);
           ^
build/default/include/c++/v1/__memory/allocator_traits.h:298:9: note: in call to 'construct_at(&{*new Counted [5][3]#2}[0][0], &counter)'
        _VSTD::construct_at(__p, _VSTD::forward<_Args>(__args)...);
        ^
```

If `std::construct_at` had support for arrays, we'd create the array using it and that would do the trick. As it is, I'm not sure how to work around it.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D106916



More information about the libcxx-commits mailing list