-
-
Notifications
You must be signed in to change notification settings - Fork 1.3k
build(linux): fix compilation with Clang #3998
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull Request Overview
This PR fixes a Clang compilation error by replacing inline initialization of variable-length arrays with explicit memset zeroing.
- Removed direct initializer usage for VLAs and added memset calls to clear memory.
- Applied the same fix to both iovs and msgs arrays in different code blocks.
Comments suppressed due to low confidence (2)
src/platform/linux/misc.cpp:427
- Consider adding a short inline comment explaining that memset is used here to zero initialize the variable-length array because direct initializer lists are not supported by Clang.
struct iovec iovs[(send_info.headers ? std::min(seg_max, send_info.block_count) : 1) * max_iovs_per_msg];
src/platform/linux/misc.cpp:511
- Similarly, add a brief comment alongside the memset calls for msgs and iovs to clarify that this approach is a workaround for Clang's limitations with variable-length array initialization.
struct mmsghdr msgs[send_info.block_count];
Clang 20.1.7 fails with the following error: ``` /var/tmp/portage/net-misc/sunshine-2025.122.141614/work/Sunshine-2025.122.141614/src/platform/linux/misc.cpp:427:25: error: variable-sized object may not be initialized 427 | struct iovec iovs[(send_info.headers ? std::min(seg_max, send_info.block_count) : 1) * max_iovs_per_msg] = {}; | ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ``` As VLAs are not part of the C++ standard, Clang barely support of their features. However, simple memset fixes the issue.
|
Bundle ReportBundle size has no change ✅ |
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## master #3998 +/- ##
==========================================
- Coverage 11.37% 11.37% -0.01%
==========================================
Files 92 92
Lines 17549 17553 +4
Branches 8232 8231 -1
==========================================
Hits 1996 1996
+ Misses 14868 13037 -1831
- Partials 685 2520 +1835
Flags with carried forward coverage won't be shown. Click here to find out more.
|
Thanks for the contribution. I'm going to just remove the zeroing in #4052 since it's a bit overzealous anyway. |
Description
Clang 20.1.7 fails with the following error:
As VLAs are not part of the C++ standard, Clang barely supports their features. However, simple memset fixes the issue.
Issues Fixed or Closed
Type of Change
.github/...
)Checklist