Skip to content

halp: fix std::span narrowing in cpu_buffer_input::cast() on 32-bit (wasm)#166

Merged
jcelerier merged 1 commit into
mainfrom
fix-buffer-wasm-narrowing
Jul 9, 2026
Merged

halp: fix std::span narrowing in cpu_buffer_input::cast() on 32-bit (wasm)#166
jcelerier merged 1 commit into
mainfrom
fix-buffer-wasm-narrowing

Conversation

@jcelerier

Copy link
Copy Markdown
Member

Problem

raw_buffer::byte_size is int64_t, so byte_size / sizeof(T) stays 64-bit and
narrows to std::span's size_type in the braced initializer of
cpu_buffer_input::cast(). With 64-bit size_t the conversion is silent, but where
size_t is 32-bit (wasm/emscripten) it fails under -Wc++11-narrowing
breaking e.g. score-addon-cv's wasm CI lane.

Fix

Cast the element count to std::size_t explicitly (both cast() overloads).

🤖 Generated with Claude Code

https://claude.ai/code/session_014Z4KK2Rays9dTj8J2AJcFZ

raw_buffer::byte_size is int64_t, so 'byte_size / sizeof(T)' stays 64-bit and
narrows to std::span's size_type in the braced initializer. On 64-bit size_t the
conversion is silent, but where size_t is 32-bit (wasm/emscripten) it fails to
compile under -Wc++11-narrowing. Cast the count to std::size_t explicitly.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_014Z4KK2Rays9dTj8J2AJcFZ
@jcelerier
jcelerier merged commit bd3a363 into main Jul 9, 2026
23 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.

1 participant