fix(bytes): replace std::forward<D>(d) with std::move(d) in move constructors#776
Merged
YuanYuYuan merged 1 commit intoeclipse-zenoh:mainfrom Apr 14, 2026
Merged
Conversation
…tructors MSVC 19.44 (VS 2022 17.14) rejects std::forward<D>(d) when D is deduced as decltype(d) — a local lambda type (always non-reference). The compiler cannot convert the lvalue lambda to D&&, yielding C2665/C3536. std::move(d) is the correct form here: D is never a reference type in these constructors so std::forward<D> is semantically equivalent to std::move, but newer MSVC enforces the distinction. Affects three Bytes constructors: - Bytes(std::vector<uint8_t, Allocator>&&) - Bytes(std::string&&) - Bytes(uint8_t*, size_t, Deleter) Fixes ROS 2 buildfarm Windows build failure: https://ci.ros2.org/job/ci_windows/27547/
DenisBiryukov91
approved these changes
Apr 14, 2026
YuanYuYuan
added a commit
to ZettaScaleLabs/rmw_zenoh
that referenced
this pull request
Apr 14, 2026
eclipse-zenoh/zenoh-cpp#776 fixed std::forward<D>(d) → std::move(d) in three Bytes move constructors. MSVC 19.44 (VS 2022 17.14, used by the ROS 2 Windows buildfarm) rejects std::forward on deduced lambda types with C2665/C3536. The fix is merged at a3cd1a2d. Bump zenoh_cpp_vendor to that commit to unblock ci_windows builds.
YuanYuYuan
added a commit
to ZettaScaleLabs/rmw_zenoh
that referenced
this pull request
Apr 14, 2026
eclipse-zenoh/zenoh-cpp#776 fixed std::forward<D>(d) → std::move(d) in three Bytes move constructors. MSVC 19.44 (VS 2022 17.14, used by the ROS 2 Windows buildfarm) rejects std::forward on deduced lambda types with C2665/C3536. The fix is merged at a3cd1a2d. Bump zenoh_cpp_vendor to that commit to unblock ci_windows builds.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
std::forward<D>(d)withstd::move(d)in threeBytesmove constructors inbytes.hxxRoot Cause
MSVC 19.44 (VS 2022 17.14, shipped with the ROS 2 buildfarm) rejects the pattern:
When
Dis deduced asdecltype(d)— a local lambda type — it is always a non-reference type.std::forward<D>(d)then expects aD&&argument, but MSVC 19.44 refuses to convert the lvaluedtoD&&, reporting:This is a conformance tightening introduced in a recent MSVC toolset update. Since
Dis never a reference here,std::forward<D>is semantically identical tostd::move. Usingstd::move(d)is unambiguous and correct on all compilers.Affected constructors
Bytes(std::vector<uint8_t, Allocator>&&)— line 71Bytes(std::string&&)— line 96Bytes(uint8_t*, size_t, Deleter)— line 115Context
This broke the ROS 2 buildfarm Windows CI when
rmw_zenoh_cppinstantiates these constructors. Tracked in the ROS 2 PMC discussion and visible at:https://ci.ros2.org/job/ci_windows/27547/
The fix is minimal — 3 lines changed, no behavior change on any compiler.
Breaking Changes
None