Skip to content

Remove pessimizing move from sink future return - #569

Merged
KjellKod merged 1 commit into
masterfrom
fix/issue-564-pessimizing-move
Aug 3, 2026
Merged

KjellKod merged 1 commit into
masterfrom
fix/issue-564-pessimizing-move

Conversation

@KjellKod

@KjellKod KjellKod commented Aug 3, 2026 •

Copy link
Copy Markdown
Owner

⭐ 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

  • Remove the unnecessary std::move around promise.get_future() in src/g3log/sinkhandle.hpp.
  • Preserve the existing std::bad_weak_ptr exception path for expired sinks.

Validation

  • Configure and build all targets with the warning promoted to an error: 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.
  • Run 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_sink must continue delivering std::bad_weak_ptr through the returned future after its sink has expired.

     ▐▛███▜▌
    ▝▜█████▛▘
      ▘▘ ▝▝
Quest - https://github.com/KjellKod/Quest
Co-Authored-By: Codex 
in collaboration with KjellKod

Review in cubic

@KjellKod
KjellKod marked this pull request as ready for review August 3, 2026 22:18
@KjellKod
KjellKod force-pushed the fix/issue-564-pessimizing-move branch from f94110c to a23d4c0 Compare August 3, 2026 22:19
@KjellKod
KjellKod merged commit 8ff5c3e into master Aug 3, 2026
8 checks passed
@KjellKod
KjellKod deleted the fix/issue-564-pessimizing-move branch August 3, 2026 22:24
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Moving a temporary object in sinkhandle.hpp warning

1 participant