Skip to content

Avoid macOS [[nodiscard]] on std::future<bool>::get() - #1014

Merged
christian-rauch merged 1 commit into
stevenlovegrove:masterfrom
BillyONeal:nodiscard-get
Oct 26, 2026
Merged

christian-rauch merged 1 commit into
stevenlovegrove:masterfrom
BillyONeal:nodiscard-get

Conversation

@BillyONeal

Copy link
Copy Markdown
Contributor

This code is using the side effects of get() so it is not a meaningless call.

(I do not understand why libc++ decided to nodiscard that)

This was discovered by the macOS update part of microsoft/vcpkg#54519

@qwert12131990

qwert12131990 commented Oct 23, 2026 via email

Copy link
Copy Markdown

@christian-rauch

Copy link
Copy Markdown
Collaborator

On which compiler is that? Can you reproduce this in the CI?

I don't see a [[nodiscard]] for std::future<T>::get so I wouldn't know why any compiler would trigger an error.

@BillyONeal

BillyONeal commented Oct 26, 2026 •

Copy link
Copy Markdown
Contributor Author

On which compiler is that?

The one that comes in the box with macOS 27.0.1 "Golden Gate".

Can you reproduce this in the CI?

It does in ours. It looks like the one here is on macOS 26 rather than 27 so it won't repro there. (As it did not repro in ours before I updated us)

I don't see a [[nodiscard]] for std::future<T>::get so I wouldn't know why any compiler would trigger an error.

Standard library implementations are allowed to add additional such annotations, and the libc++ maintainers have apparently decided to do so. (Speaking as a former standard library maintainer, I disagree with this one but I didn't own that implementation :) )

[73/118] /usr/bin/c++ -DHAVE_EIGEN -D_OSX_ -I/Users/builduser/Data/b/pangolin/src/v0.9.5-93bea75c25.clean/components/pango_video/include -I/Users/builduser/Data/b/pangolin/arm64-osx-dbg/include -I/Users/builduser/Data/b/pangolin/src/v0.9.5-93bea75c25.clean/components/pango_core/include -I/Users/builduser/Data/b/pangolin/src/v0.9.5-93bea75c25.clean/components/pango_image/include -I/Users/builduser/Data/b/pangolin/src/v0.9.5-93bea75c25.clean/components/pango_packetstream/include -isystem /Users/builduser/Data/installed/arm64-osx/include -isystem /Users/builduser/Data/installed/arm64-osx/include/libxml2 -isystem /Users/builduser/Data/installed/arm64-osx/debug/lib/pkgconfig/../../../include -isystem /Users/builduser/Data/installed/arm64-osx/debug/lib/pkgconfig/../../../include/srt -isystem /Users/builduser/Data/installed/arm64-osx/debug/lib/pkgconfig/../../../include/svt-av1 -isystem /Users/builduser/Data/installed/arm64-osx/include/webp -isystem /Users/builduser/Data/installed/arm64-osx/include/opus -isystem /Users/builduser/Data/installed/arm64-osx/include/openjpeg-2.5 -isystem /Users/builduser/Data/installed/arm64-osx/include/eigen3 -fPIC -g -std=gnu++17 -arch arm64 -fPIC -Wall -Wextra -Werror -Wno-parentheses -Wno-null-pointer-arithmetic -Wno-null-pointer-subtraction -Werror=vla -Wno-error=ignored-qualifiers -Wno-error=sign-compare -Wno-error=deprecated-copy -Wno-error=missing-field-initializers -Wno-error=pessimizing-move -DRTC_BUILD=0 -UEB_DLL -MD -MT CMakeFiles/pango_video.dir/components/pango_video/src/drivers/pango_video_output.cpp.o -MF CMakeFiles/pango_video.dir/components/pango_video/src/drivers/pango_video_output.cpp.o.d -o CMakeFiles/pango_video.dir/components/pango_video/src/drivers/pango_video_output.cpp.o -c /Users/builduser/Data/b/pangolin/src/v0.9.5-93bea75c25.clean/components/pango_video/src/drivers/pango_video_output.cpp
FAILED: [code=1] CMakeFiles/pango_video.dir/components/pango_video/src/drivers/pango_video_output.cpp.o 
/usr/bin/c++ -DHAVE_EIGEN -D_OSX_ -I/Users/builduser/Data/b/pangolin/src/v0.9.5-93bea75c25.clean/components/pango_video/include -I/Users/builduser/Data/b/pangolin/arm64-osx-dbg/include -I/Users/builduser/Data/b/pangolin/src/v0.9.5-93bea75c25.clean/components/pango_core/include -I/Users/builduser/Data/b/pangolin/src/v0.9.5-93bea75c25.clean/components/pango_image/include -I/Users/builduser/Data/b/pangolin/src/v0.9.5-93bea75c25.clean/components/pango_packetstream/include -isystem /Users/builduser/Data/installed/arm64-osx/include -isystem /Users/builduser/Data/installed/arm64-osx/include/libxml2 -isystem /Users/builduser/Data/installed/arm64-osx/debug/lib/pkgconfig/../../../include -isystem /Users/builduser/Data/installed/arm64-osx/debug/lib/pkgconfig/../../../include/srt -isystem /Users/builduser/Data/installed/arm64-osx/debug/lib/pkgconfig/../../../include/svt-av1 -isystem /Users/builduser/Data/installed/arm64-osx/include/webp -isystem /Users/builduser/Data/installed/arm64-osx/include/opus -isystem /Users/builduser/Data/installed/arm64-osx/include/openjpeg-2.5 -isystem /Users/builduser/Data/installed/arm64-osx/include/eigen3 -fPIC -g -std=gnu++17 -arch arm64 -fPIC -Wall -Wextra -Werror -Wno-parentheses -Wno-null-pointer-arithmetic -Wno-null-pointer-subtraction -Werror=vla -Wno-error=ignored-qualifiers -Wno-error=sign-compare -Wno-error=deprecated-copy -Wno-error=missing-field-initializers -Wno-error=pessimizing-move -DRTC_BUILD=0 -UEB_DLL -MD -MT CMakeFiles/pango_video.dir/components/pango_video/src/drivers/pango_video_output.cpp.o -MF CMakeFiles/pango_video.dir/components/pango_video/src/drivers/pango_video_output.cpp.o.d -o CMakeFiles/pango_video.dir/components/pango_video/src/drivers/pango_video_output.cpp.o -c /Users/builduser/Data/b/pangolin/src/v0.9.5-93bea75c25.clean/components/pango_video/src/drivers/pango_video_output.cpp
/Users/builduser/Data/b/pangolin/src/v0.9.5-93bea75c25.clean/components/pango_video/src/drivers/pango_video_output.cpp:253:13: error: ignoring return value of function declared with 'nodiscard' attribute [-Werror,-Wunused-result]
  253 |             encode_finished[i-1].get();
      |             ^~~~~~~~~~~~~~~~~~~~~~~~
1 error generated.

@BillyONeal

Copy link
Copy Markdown
Contributor Author

@christian-rauch Looks like macOS CI here is already broken; I certainly didn't change how libraw is found by cmake by adding a (void) cast :)

It looks like vcpkg's lab isn't seeing that failure because we explicitly disable it:

https://github.com/microsoft/vcpkg/blob/817892b0ecbc6af994dd6df999c73faf795adbf2/ports/pangolin/portfile.cmake#L50

@christian-rauch

Copy link
Copy Markdown
Collaborator

On which compiler is that?

The one that comes in the box with macOS 27.0.1 "Golden Gate".

Can you reproduce this in the CI?

It does in ours. It looks like the one here is on macOS 26 rather than 27 so it won't repro there. (As it did not repro in ours before I updated us)

There are no macOS 27 public GitHub runners yet: https://docs.github.com/en/actions/reference/runners/github-hosted-runners. There is only macos-26 and xcode-27, which may have the same compiler.

I don't see a [[nodiscard]] for std::future<T>::get so I wouldn't know why any compiler would trigger an error.

Standard library implementations are allowed to add additional such annotations, and the libc++ maintainers have apparently decided to do so. (Speaking as a former standard library maintainer, I disagree with this one but I didn't own that implementation :) )

It seems like different OSes use different libstdc++ implementations? At least the libc++ 15 version on Ubuntu (/usr/include/c++/15/future) does not have this. Maybe this is LLVM specific.

In any case, I do not have macOS to reproduce these issues. I can have a look at fixing the "wheel" issue with Python on macOS.

@BillyONeal

Copy link
Copy Markdown
Contributor Author

There are no macOS 27 public GitHub runners yet:

Yes we have our own because all the GitHub provided ones don't have enough performance to reasonably build all 2800 things.

At least the libc++ 15 version on Ubuntu (/usr/include/c++/15/future) does not have this. Maybe this is LLVM specific.

Ubuntu comes with libstdc++, not libc++. (clang has a switch to switch if you want but it won't be in /usr/include/c++)

This code is using the side effects of get() so it is not a meaningless call.

(I do not understand why libc++ decided to nodiscard that)
@christian-rauch
christian-rauch merged commit 42963ca into stevenlovegrove:master Oct 26, 2026
18 checks passed
@BillyONeal
BillyONeal deleted the nodiscard-get branch October 26, 2026 20:14
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.

3 participants