Skip to content

Spell out Negentropy's template argument so Apple clang 16 can build - #266

Open
kojira wants to merge 1 commit into
hoytech:masterfrom
kojira:fix/negentropy-ctad-clang16
Open

Spell out Negentropy's template argument so Apple clang 16 can build#266
kojira wants to merge 1 commit into
hoytech:masterfrom
kojira:fix/negentropy-ctad-clang16

Conversation

@kojira

@kojira kojira commented Sep 3, 2026

Copy link
Copy Markdown
Contributor

Fixes #265.

Problem

Negentropy ne(storage, ...) deduces the template argument through an alias template:

template<typename T>
using Negentropy = negentropy::Negentropy<T>;   // external/negentropy/cpp/negentropy.h

CTAD through an alias template is a C++20 feature (P1814). Apple clang 16 — the compiler shipped with the current Xcode Command Line Tools on macOS 15 — does not implement it, so a stock macOS build fails:

src/apps/relay/RelayNegentropy.cpp:99:24: error: alias template 'Negentropy' requires template arguments; argument deduction only allowed for class templates

The macos-latest CI runner carries a newer clang (17) that supports it, which is why the macOS workflow stays green while local builds on macOS 15 break.

Fix

Name the argument explicitly at the five call sites (one in RelayNegentropy.cpp, four in cmd_sync.cpp):

Negentropy<std::remove_reference_t<decltype(storage)>> ne(storage, ...);

This is a no-op wherever deduction already worked, and needs no per-site knowledge of the storage type.

Verified

Platform Compiler Before After
macOS 15.2, x86_64 Apple clang 16.0.0 ❌ error above ✅ builds, strfry 1.1.2-146-gc65da49 runs
macOS, arm64 Apple clang 17.0.0 ✅ (unchanged)

Thanks for the recent macOS work (#190, #210) — with those in, this was the only thing left standing between master and a clean build on a current stock macOS install.

🤖 Generated with Claude Code

https://claude.ai/code/session_01699ff9NNv1NUxH9nmh8mqd

`Negentropy ne(storage, ...)` relies on class template argument deduction
through an alias template (`template<typename T> using Negentropy =
negentropy::Negentropy<T>`). That is a C++20 feature (P1814) which Apple
clang 16 -- the compiler shipped with the current Xcode Command Line Tools on
macOS 15 -- does not implement, so the build fails with:

  src/apps/relay/RelayNegentropy.cpp:99:24: error: alias template 'Negentropy'
  requires template arguments; argument deduction only allowed for class
  templates

The macOS CI job passes because `macos-latest` carries a newer clang (17)
that supports alias-template CTAD. Anyone building on a stock macOS 15
install hits it.

Name the argument explicitly at all five call sites:

  Negentropy<std::remove_reference_t<decltype(storage)>> ne(storage, ...);

This is a no-op on compilers that already deduced it, and lets clang 16 build.
Verified: pristine master fails on Apple clang 16.0.0 (x86_64, macOS 15.2);
with this change it builds and runs there, and it still builds unchanged on
Apple clang 17 (arm64).

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01699ff9NNv1NUxH9nmh8mqd
@kojira
kojira force-pushed the fix/negentropy-ctad-clang16 branch from 2115316 to 1e803b8 Compare September 3, 2026 16:20
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.

Build fails on Apple clang 16: alias-template CTAD in Negentropy call sites

1 participant