[PATCH] D114903: [clang] Support array placement new in constant expressions

Arthur O'Dwyer via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Mon Jan 31 12:10:57 PST 2022


Quuxplusone added a comment.

I have no special knowledge of this. Seems like "it can't be that easy," but I don't know.



================
Comment at: clang/test/SemaCXX/cxx2a-constexpr-dynalloc.cpp:138
 }
 static_assert(call_std_construct_at());
 
----------------
I would think you ought to have the same species of test for the array case, also. Could probably be added right in here:
```
  std::construct_at<int>(p + 2, 3);
  bool good = p[0] + p[1] + p[2] == 6;
  std::construct_at<int[3]>(p, 4, 5, 6);
  bool also_good = p[0] + p[1] + p[2] == 15;
```
Also, it would be good to test the behavior of `using T = int[]; new (&a) T{}` with an incomplete type, unless that's already tested somewhere.
Also note this test is compile-only (since it expects errors), and so it would probably be a good idea to have some tests for the behavior/codegen, not just that it seems to be accepted silently by the compiler (and in the presence of other errors at that).


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D114903



More information about the cfe-commits mailing list