halp: fix std::span narrowing in cpu_buffer_input::cast() on 32-bit (wasm)#166
Merged
Conversation
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
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
raw_buffer::byte_sizeisint64_t, sobyte_size / sizeof(T)stays 64-bit andnarrows to
std::span'ssize_typein the braced initializer ofcpu_buffer_input::cast(). With 64-bitsize_tthe conversion is silent, but wheresize_tis 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_texplicitly (bothcast()overloads).🤖 Generated with Claude Code
https://claude.ai/code/session_014Z4KK2Rays9dTj8J2AJcFZ