Skip to content

Fix clang-cl build: avoid MSVC STL vectorized find on 16-byte StreamId - #30

Merged
christianparpart merged 1 commit into
masterfrom
fix/clangcl-vectorized-find-streamid
Jul 8, 2026
Merged

Fix clang-cl build: avoid MSVC STL vectorized find on 16-byte StreamId#30
christianparpart merged 1 commit into
masterfrom
fix/clangcl-vectorized-find-streamid

Conversation

@christianparpart

Copy link
Copy Markdown
Member

The clangcl-debug and clangcl-release presets fail to compile CacheEngine.cpp against the latest MSVC STL (14.51) with clang 22:

xutility(320): error: static assertion failed: unexpected size
note: in instantiation of '_Find_vectorized<StreamCodec::StreamId, ...>'

Under clang, the MSVC STL trait _Is_same_and_builtin_trivially_equality_comparable uses the __is_trivially_equality_comparable builtin, which reports StreamId (two uint64_t, defaulted operator<=>) as eligible for the vectorized find fast path. That path only handles 1/2/4/8-byte elements and hard-errors on StreamId's 16 bytes. Plain MSVC cl hard-codes the trait to false, so only clang-cl trips over it.

The identity-projected std::ranges::find(wanted, p.id) in StreamClaim's predicate was the sole trigger — the other find/count calls either pass a projection (which skips the vectorized path) or search 8-byte / string ranges. It is replaced with a predicate-based std::ranges::none_of, matching the idiom already used a few lines above, with a comment explaining why plain find is avoided so it is not "simplified" back.

No behavior change. All clangcl-debug (830) and clangcl-release (828, smoke excluded) tests pass.

…clang-cl

Building with the clang-cl presets against the latest MSVC STL (14.51)
fails to compile CacheEngine.cpp:

  xutility(320): error: static assertion failed: unexpected size
  note: in instantiation of '_Find_vectorized<StreamCodec::StreamId, ...>'

Under clang the MSVC STL trait
`_Is_same_and_builtin_trivially_equality_comparable` uses the
`__is_trivially_equality_comparable` builtin, which reports StreamId (two
uint64_t, defaulted operator<=>) as eligible for the vectorized find fast
path. That path (`_Find_vectorized`) only handles 1/2/4/8-byte elements
and hard-errors on StreamId's 16 bytes. Plain MSVC `cl` hard-codes the
trait to false, so only clang-cl trips over it.

The identity-projected `std::ranges::find(wanted, p.id)` in StreamClaim's
predicate was the sole trigger; the other find/count calls pass a
projection (skipping the vectorized path) or search 8-byte/string ranges.
Replace it with a predicate-based `std::ranges::none_of`, matching the
idiom already used a few lines above, and comment why plain find is
avoided.

No behavior change; all clangcl-debug (830) and clangcl-release (828,
smoke excluded) tests pass.

Signed-off-by: Christian Parpart <c.parpart@lastrada.net>
@christianparpart
christianparpart merged commit 2dfd3ad into master Jul 8, 2026
11 checks passed
@christianparpart
christianparpart deleted the fix/clangcl-vectorized-find-streamid branch July 8, 2026 21:28
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