From b6dab5c76fd31e7e495627b0c25191681e649258 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jean-Micha=C3=ABl=20Celerier?= Date: Thu, 9 Jul 2026 00:01:21 -0400 Subject: [PATCH] halp: fix std::span narrowing in cpu_buffer_input::cast() on 32-bit 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) Claude-Session: https://claude.ai/code/session_014Z4KK2Rays9dTj8J2AJcFZ --- include/halp/buffer.hpp | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/include/halp/buffer.hpp b/include/halp/buffer.hpp index de8b99fa..2b85f967 100644 --- a/include/halp/buffer.hpp +++ b/include/halp/buffer.hpp @@ -65,13 +65,15 @@ struct cpu_buffer_input auto cast() { return std::span{ - reinterpret_cast(buffer.raw_data), buffer.byte_size / sizeof(T)}; + reinterpret_cast(buffer.raw_data), + static_cast(buffer.byte_size / sizeof(T))}; } template auto cast() const noexcept { return std::span{ - reinterpret_cast(buffer.raw_data), buffer.byte_size / sizeof(T)}; + reinterpret_cast(buffer.raw_data), + static_cast(buffer.byte_size / sizeof(T))}; } halp::raw_buffer buffer{};