Summary: Clang warns when types with vtables are memcpy'd. If the type
has declared itself to be relocatable, then this is the desired
behavior. If the type has not declared itself to be relocatable, then
the memcpy codepath is dead. However, the dead codepath is still
instantiated (it's inside an if block with a static check, but c++
doesn't have static-if), so the compiler spits out a nasty warning
anyways.
Each memcpy reference inside of fbvector has been void-ified. I have
looked at all the codepaths leading to the memcpys, and see that they
have isRelocatable or isTriviallyCopyable checks.
Reviewed By: @markisaa
Differential Revision:
D2148286
static void
S_uninitialized_copy_bits(T* dest, const T* first, const T* last) {
static void
S_uninitialized_copy_bits(T* dest, const T* first, const T* last) {
- std::memcpy(dest, first, (last - first) * sizeof(T));
+ std::memcpy((void*)dest, (void*)first, (last - first) * sizeof(T));
std::move_iterator<T*> last) {
T* bFirst = first.base();
T* bLast = last.base();
std::move_iterator<T*> last) {
T* bFirst = first.base();
T* bLast = last.base();
- std::memcpy(dest, bFirst, (bLast - bFirst) * sizeof(T));
+ std::memcpy((void*)dest, (void*)bFirst, (bLast - bFirst) * sizeof(T));
static const T* S_copy_n(T* dest, const T* first, size_type n) {
if (folly::IsTriviallyCopyable<T>::value) {
static const T* S_copy_n(T* dest, const T* first, size_type n) {
if (folly::IsTriviallyCopyable<T>::value) {
- std::memcpy(dest, first, n * sizeof(T));
+ std::memcpy((void*)dest, (void*)first, n * sizeof(T));
return first + n;
} else {
return S_copy_n<const T*>(dest, first, n);
return first + n;
} else {
return S_copy_n<const T*>(dest, first, n);
S_copy_n(T* dest, std::move_iterator<T*> mIt, size_type n) {
if (folly::IsTriviallyCopyable<T>::value) {
T* first = mIt.base();
S_copy_n(T* dest, std::move_iterator<T*> mIt, size_type n) {
if (folly::IsTriviallyCopyable<T>::value) {
T* first = mIt.base();
- std::memcpy(dest, first, n * sizeof(T));
+ std::memcpy((void*)dest, (void*)first, n * sizeof(T));
return std::make_move_iterator(first + n);
} else {
return S_copy_n<std::move_iterator<T*>>(dest, mIt, n);
return std::make_move_iterator(first + n);
} else {
return S_copy_n<std::move_iterator<T*>>(dest, mIt, n);
}
void relocate_move_or_memcpy(T* dest, T* first, T* last, std::true_type) {
}
void relocate_move_or_memcpy(T* dest, T* first, T* last, std::true_type) {
- std::memcpy(dest, first, (last - first) * sizeof(T));
+ std::memcpy((void*)dest, (void*)first, (last - first) * sizeof(T));
}
void relocate_move_or_memcpy(T* dest, T* first, T* last, std::false_type) {
}
void relocate_move_or_memcpy(T* dest, T* first, T* last, std::false_type) {
if (folly::IsRelocatable<T>::value && usingStdAllocator::value) {
D_destroy_range_a((iterator)first, (iterator)last);
if (last - first >= cend() - last) {
if (folly::IsRelocatable<T>::value && usingStdAllocator::value) {
D_destroy_range_a((iterator)first, (iterator)last);
if (last - first >= cend() - last) {
- std::memcpy((iterator)first, last, (cend() - last) * sizeof(T));
+ std::memcpy((void*)first, (void*)last, (cend() - last) * sizeof(T));
} else {
std::memmove((iterator)first, last, (cend() - last) * sizeof(T));
}
} else {
std::memmove((iterator)first, last, (cend() - last) * sizeof(T));
}