Skip to content

Fix -Wunused-result error on std::future::get() with newer Clang - #402

Open
mentalfl0w wants to merge 1 commit into
an-tao:masterfrom
mentalfl0w:patch-1
Open

Fix -Wunused-result error on std::future::get() with newer Clang#402
mentalfl0w wants to merge 1 commit into
an-tao:masterfrom
mentalfl0w:patch-1

Conversation

@mentalfl0w

@mentalfl0w mentalfl0w commented Jun 20, 2026

Copy link
Copy Markdown

Problem

Building with recent Clang (macOS 27 SDK / Xcode 27) fails when -Werror is enabled:

TaskQueue.h:52:9: error: ignoring return value of function declared with
'nodiscard' attribute [-Werror,-Wunused-result]
   52 |         fut.get();

std::future::get() is now annotated [[nodiscard]] in newer libc++, and trantor compiles with -Wall -Wextra -Werror.

Fix

Add (void) cast to explicitly discard the return value, which is the conventional way to suppress this warning.

Testing

  • Built successfully with Apple Clang on macOS 27 (arm64) with -Werror.

Newer Clang (shipped with macOS 27 / Xcode 26) marks std::future::get()
as [[nodiscard]], causing -Werror builds to fail:

  TaskQueue.h:52:9: error: ignoring return value of function
  declared with 'nodiscard' attribute [-Werror,-Wunused-result]

Explicitly cast to (void) to acknowledge the discarded return value.
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.

1 participant