From a42f898d354c32c55c230e9f7efe00c50ac3ec01 Mon Sep 17 00:00:00 2001 From: markaalonzo Date: Fri, 17 Apr 2026 01:25:07 -0400 Subject: [PATCH] fix: use int8_t for GGUF bool array loading instead of platform-dependent bool (#1648) Upstream: llama.cpp#21428. GGUF stores bools as 1-byte int8_t but the loader was casting through (const bool*) which has implementation-defined sizeof. Use explicit int8_t cast with != 0 normalization. Co-authored-by: Mark Alonzo --- src/llama-model-loader.cpp | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/llama-model-loader.cpp b/src/llama-model-loader.cpp index b986ae6c..a871a035 100644 --- a/src/llama-model-loader.cpp +++ b/src/llama-model-loader.cpp @@ -724,8 +724,8 @@ bool llama_model_loader::get_arr(const std::string & key, std::vector & resul result.resize(arr_info.length); if (arr_info.gt == GGUF_TYPE_BOOL) { - std::transform((const bool *)arr_info.data, (const bool *)arr_info.data + arr_info.length, result.begin(), - [] (bool x) { return static_cast(x); }); + std::transform((const int8_t *)arr_info.data, (const int8_t *)arr_info.data + arr_info.length, result.begin(), + [] (int8_t x) { return static_cast(x != 0); }); } else { result.assign((const T*)arr_info.data, (const T *)arr_info.data + arr_info.length); @@ -762,8 +762,8 @@ bool llama_model_loader::get_arr(const std::string & key, std::array & } if (arr_info.gt == GGUF_TYPE_BOOL) { - std::transform((const bool *)arr_info.data, (const bool *)arr_info.data + arr_info.length, result.begin(), - [] (bool x) { return static_cast(x); }); + std::transform((const int8_t *)arr_info.data, (const int8_t *)arr_info.data + arr_info.length, result.begin(), + [] (int8_t x) { return static_cast(x != 0); }); } else { std::copy((const T*)arr_info.data, (const T *)arr_info.data + arr_info.length, result.begin()); }