Issue 233870
Summary [Clang] Allow `__builtin_mem{cpy, move}` to construct implicit lifetime objects
Labels clang
Assignees
Reporter philnik777
    Currently Clang doesn't allow `memmove`ing into uninitialized memory during constant evaluation, even though it's perfectly defined during runtime, AFAICT shouldn't be difficult to implement, and quite useful:

```c++
#include <memory>

static_assert([] {
  auto alloc = std::allocator<int>().allocate(4);

  int arr[] = {1, 2, 3, 4};
 __builtin_memmove(alloc, arr, sizeof(int) * 4); // expected-note {{assignment to object outside its lifetime}}

  std::allocator<int>().deallocate(alloc, 4);

  return true;
}());
```

https://godbolt.org/z/jovxKxzvf

CC @tbaederr 
_______________________________________________
llvm-bugs mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-bugs

Reply via email to