Skip to content

Fix the build with C++20 and C++23 - #549

Merged
lo-simon merged 1 commit into
sony:masterfrom
garethsb:bugfix/cxx23-build
Nov 18, 2026
Merged

lo-simon merged 1 commit into
sony:masterfrom
garethsb:bugfix/cxx23-build

Conversation

@garethsb

Copy link
Copy Markdown
Contributor

Prepares for a C++23 CI job, without adding one.

Building with CMAKE_CXX_STANDARD=23 on ubuntu-26.04 (GCC 15) failed in two ways:

  • C++23 treats a returned local variable as an rvalue (P2266), and an rvalue cannot bind to the non-const copy constructor of Catch's OptBuilder, so catch.hpp did not compile. This PR makes the copy constructor take a const reference.
  • C++20 deprecates the implicit capture of this by [=], and GCC warns about it, which would fail a build with warnings as errors. This PR captures this explicitly in slog's async_log_service, and uses a local pointer in the mDNS service advertiser, as the service discovery implementation already does. Writing [=, this] instead would warn before C++20.

With this change, a throwaway run on my fork built at C++23 on ubuntu-26.04, with and without Conan, passed all the unit tests, and passed the AMWA test suites (https://github.com/garethsb/nmos-cpp/actions/runs/44361063182). The mDNS test failed there the same way as on ubuntu-24.04 on master.

The non-Conan job in that run also showed two implicit this warnings in cpprestsdk's ws_client.cpp, which cpprest-lts/cpprestsdk#69 fixes.

Co-authored-by: Gareth's 🤖 buddy

C++20 deprecates the implicit capture of this by [=], and GCC warns
about it, so capture this explicitly in slog's async_log_service, and
use a local pointer in the mDNS service advertiser, as the service
discovery implementation already does.

C++23 treats a returned local variable as an rvalue, which cannot bind
to the non-const copy constructor of Catch's OptBuilder, so take a const
reference instead.

Signed-off-by: Gareth Sylvester-Bradley <garethsb@nvidia.com>

@lo-simon lo-simon left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@lo-simon
lo-simon merged commit fabb2ad into sony:master Nov 18, 2026
12 checks passed
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.

2 participants