Skip to content

pro_backend: fix macOS build of the C response holders - #120

Merged
jagerman merged 1 commit into
session-foundation:devfrom
Bilb:fix-macos-paren-aggregate-init
Aug 6, 2026
Merged

pro_backend: fix macOS build of the C response holders#120
jagerman merged 1 commit into
session-foundation:devfrom
Bilb:fix-macos-paren-aggregate-init

Conversation

@Bilb

@Bilb Bilb commented Aug 6, 2026

Copy link
Copy Markdown
Collaborator

Problem

The macOS jobs fail to compile src/pro_backend.cpp while Linux is green:

error: no matching constructor for initialization of 'GetProRevocationsCResponse'
  return unique_ptr<_Tp>(new _Tp(_VSTD::forward<_Args>(__args)...));
note: in instantiation of function template specialization
      'std::make_unique<GetProRevocationsCResponse, session::pro_backend::GetProRevocationsResponse>'
note: candidate constructor (the implicit copy constructor) not viable ...
note: candidate constructor (the implicit move constructor) not viable ...
note: candidate constructor (the implicit default constructor) not viable: requires 0 arguments, but 1 was provided

Same failure for GetPaymentDetailsCResponse. Seen on the Xcode 15.4 runners, e.g. https://github.com/session-foundation/libsession-util-nodejs/actions/runs/31062340831/job/92492725217?pr=66

Cause

GetProRevocationsCResponse / GetPaymentDetailsCResponse are aggregates deriving from their C++ response type, and the *_parse functions build them straight from a parsed base response:

std::make_unique<GetProRevocationsCResponse>(parse_revocations({json, json_len}));

make_unique initializes with parentheses (new T(args...)), so initializing an aggregate that way requires P0960R3 (parenthesized aggregate initialization, C++20). GCC implements it — hence green Linux builds — but the Apple Clang on the macOS runners does not, so it looks for a constructor, finds only the implicit copy/move/default ones, and none accept a base-class argument.

It is not a bad pin or a stale submodule: the code is only ever valid on compilers that have P0960.

Fix

Give each holder an explicit base-slice constructor, so the existing call sites resolve to a real constructor on every compiler. Call sites are unchanged.

The defaulted default constructor is kept deliberately — set_c_protocol_error<Owned> default-constructs these to carry a diagnostic:

auto owned = std::make_unique<Owned>();

Declaring it = default on first declaration keeps it non-user-provided, so make_unique<Owned>() still value-initializes exactly as it did while the type was an aggregate.

Verification

  • Reduced repro of the pattern: fails to compile as-is under -std=c++17 (a faithful stand-in for a compiler without P0960, and it reproduces the identical "no matching constructor" diagnostic), compiles with the fix. Checked under both GCC 15 and Clang 21, at C++17 and C++20.
  • src/pro_backend.cpp syntax-checks clean with the project's real compile flags from compile_commands.json.
  • clang-format reports no changes against the repo's .clang-format.

I could not build on macOS directly, so the Apple Clang leg is inferred from the reduced repro rather than observed — worth letting CI confirm.

GetProRevocationsCResponse and GetPaymentDetailsCResponse are aggregates
deriving from their C++ response, and the matching *_parse functions build
them with std::make_unique from a parsed base response. make_unique
initializes with parentheses, so that only works where the compiler
implements P0960R3 (parenthesized aggregate initialization, C++20). GCC does,
which is why the Linux builds are green, but the Apple Clang on the macOS CI
runners does not -- it looks for a constructor, finds none, and fails with
"no matching constructor for initialization of GetProRevocationsCResponse".

Give each holder an explicit base-slice constructor so the call sites resolve
to a real constructor on every compiler. The defaulted default constructor is
kept because set_c_protocol_error<Owned> default-constructs these to carry a
diagnostic.
@jagerman
jagerman merged commit b5da6f0 into session-foundation:dev Aug 6, 2026
1 check passed
jagerman pushed a commit that referenced this pull request Aug 6, 2026
Forward-port of #120 (dev commit b63b4b0) onto pfs; applies unmodified.

GetProRevocationsCResponse / GetPaymentDetailsCResponse are aggregates built
by the *_parse functions via std::make_unique from a parsed base response.
make_unique initializes with parentheses, which only aggregate-initializes
under P0960R3 (C++20): GCC implements it, the Apple Clang on the macOS CI
runners does not, so it looks for a constructor and finds none.  Give each an
explicit base-slice constructor; call sites are unchanged.

pfs has the same structs and the same make_unique call sites, so it has the
same latent macOS break.
jagerman added a commit that referenced this pull request Aug 6, 2026
Records dev up to 2b27d27 as merged, keeping pfs's tree unchanged (-s ours).
All four PRs in the range are now applied to pfs:

- #116 (this-is-not-c)                 via #115 this-is-not-c-pfs
- #118 (renewal-target-no-proof-fetch) via #119 renewal-target-no-proof-fetch-pfs
- #120 (macOS C response holders)      forward-ported in e682e6b
- #114 (fixed-size XEd25519 spans)     forward-ported in b03709d

Verified for the two that were already applied: #119's user_profile.cpp change
is line-identical to #118's, and for #116/#115 the `errs` error-vector is gone
from both branches with identical parse_error usage.
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