[libc-commits] [PATCH] D157653: [libc][WIP] move realloc into alloc_checker

Roland McGrath via Phabricator via libc-commits libc-commits at lists.llvm.org
Fri Aug 11 15:16:54 PDT 2023


mcgrathr added a comment.

In D157653#4580990 <https://reviews.llvm.org/D157653#4580990>, @sivachandra wrote:

> Should we restrict this to trivially destructible types?

realloc should be restricted to trivially copyable types, because realloc is going to copy them byte-by-byte for the existing elements in the array.
It doesn't really need to be restricted to trivially destructible types, because eventual `delete[]` should still work as it would with any array from `new[]`.
Likewise, if we had a front-end for the trimming case, then that could explicitly call destructors on the tail elements if need be.

That said, it seems unlikely we'll ever use this for things that aren't trivially destructible, or even anything for which we're not doing uninitialized default initialization, so having conservative static_assert for now and revisiting when use cases arise seems sensible.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D157653



More information about the libc-commits mailing list