Remove pessimizing move from sink future return - #569
Merged
Merged
Conversation
KjellKod
marked this pull request as ready for review
August 3, 2026 22:18
KjellKod
force-pushed
the
fix/issue-564-pessimizing-move
branch
from
August 3, 2026 22:19
f94110c to
a23d4c0
Compare
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.
⭐ Why this matters
Consumers compiling g3log with warnings treated as errors can currently fail on an unnecessary
std::move, as reported in #564. This change restores clean compilation without changing future ownership or exception delivery.Summary
Return the temporary future directly from
SinkHandle::call()so compilers can perform copy elision and avoid-Wpessimizing-move. Fixes #564.Changes
std::movearoundpromise.get_future()insrc/g3log/sinkhandle.hpp.std::bad_weak_ptrexception path for expired sinks.Validation
cmake -S . -B build-issue-564 -DCMAKE_BUILD_TYPE=Release -DADD_G3LOG_UNIT_TEST=ON -DADD_G3LOG_BENCH_PERFORMANCE=ON -DPRETTY_FUNCTION=ON "-DCMAKE_CXX_FLAGS=-Wpessimizing-move -Werror=pessimizing-move" && cmake --build build-issue-564 --config Release --parallel. Expected: the complete build succeeds without a pessimizing-move diagnostic.ctest --test-dir build-issue-564 -C Release --output-on-failure. Expected: every discovered test passes; the current macOS/Linux suite reports 8/8 passing.Watch for:
test_concept_sinkmust continue deliveringstd::bad_weak_ptrthrough the returned future after its sink has expired.▐▛███▜▌ ▝▜█████▛▘ ▘▘ ▝▝ Quest - https://github.com/KjellKod/Quest Co-Authored-By: Codex in collaboration with KjellKod