Skip to content

Commit 09c6944

Browse files
drodriguezmeta-codesync[bot]
authored andcommitted
Fix 5 instances of -Wvla-cxx-extension
Summary: While Clang (and GCC) supports the usage of Variable Length Arrays (VLA) in C++, they are not part of the standard. In Clang 19 a warning is issued for the usages of VLA in C++, to indicate that the feature is not standard and will cause compatibility problems. When -Werror is used, the warning becomes a fatal error and compilation will fail. Besides that, the usage of VLA can increase the stack requirements of the functions that use them, and in C++ one can use standard containers for the same effect without the warning or the huge stack allocations. The VLA are transformed into usages of `std::vector` or `std::string` were appropiate, and in a couple of cases, a `sizeof` of a VLA is transformed into a `sizeof` of the base type multiplied by the VLA count. The fatal error was suppressed globally as part of the Pika 16.3 upgrade, but we are removing the toolchain suppression in D89382996 to try to avoid more instances of the problem, and these were some instances found during testing. Differential Revision: D89714003 fbshipit-source-id: 87e5b20f3a4909b4b8708ea0961184d2823eab9f
1 parent 9ef6778 commit 09c6944

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

eden/common/utils/UnixSocket.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -427,7 +427,7 @@ UnixSocket::SendQueueEntry::SendQueueEntry(
427427
void UnixSocket::SendQueueDestructor::operator()(SendQueueEntry* entry) const {
428428
#if __cpp_sized_deallocation
429429
size_t allocationSize =
430-
sizeof(SendQueueEntry) + sizeof(struct iovec[entry->iovCount]);
430+
sizeof(SendQueueEntry) + sizeof(struct iovec) * entry->iovCount;
431431
entry->~SendQueueEntry();
432432
operator delete(entry, allocationSize);
433433
#else
@@ -445,7 +445,7 @@ UnixSocket::SendQueuePtr UnixSocket::createSendQueueEntry(
445445
enumerateIovecs(message.data, [&](const auto&) { ++iovecElements; });
446446

447447
size_t allocationSize =
448-
sizeof(SendQueueEntry) + sizeof(struct iovec[iovecElements]);
448+
sizeof(SendQueueEntry) + sizeof(struct iovec) * iovecElements;
449449
SendQueuePtr entry;
450450
void* data = operator new(allocationSize);
451451
try {

0 commit comments

Comments
 (0)