From 07b53077ab4dc4dd9d857ab639169fd14d7000ca Mon Sep 17 00:00:00 2001 From: Melvin Carvalho Date: Fri, 9 Jan 2026 16:46:59 +0100 Subject: [PATCH] Fix GCC 13+ build error: blake2.h alignment constraints GCC 13 enforces stricter alignment rules. The blake2s_state and blake2b_state structs were declared with ALIGN(64) but used in arrays inside #pragma pack(push, 1), causing build failures: error: size of array element is not a multiple of its alignment Fix by: 1. Remove ALIGN(64) from state structs (not needed for reference impl) 2. Move #pragma pack(pop) before parallel state structures Fixes #143 --- src/blake2.h | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/src/blake2.h b/src/blake2.h index f8aba833ed..aa19a30c8f 100644 --- a/src/blake2.h +++ b/src/blake2.h @@ -61,7 +61,7 @@ extern "C" { uint8_t personal[BLAKE2S_PERSONALBYTES]; // 32 } blake2s_param; - ALIGN( 64 ) typedef struct __blake2s_state + typedef struct __blake2s_state { uint32_t h[8]; uint32_t t[2]; @@ -86,7 +86,7 @@ extern "C" { uint8_t personal[BLAKE2B_PERSONALBYTES]; // 64 } blake2b_param; - ALIGN( 64 ) typedef struct __blake2b_state + typedef struct __blake2b_state { uint64_t h[8]; uint64_t t[2]; @@ -95,7 +95,9 @@ extern "C" { size_t buflen; uint8_t last_node; } blake2b_state; +#pragma pack(pop) + // Parallel state structures - outside pack(1) due to aligned member arrays typedef struct __blake2sp_state { blake2s_state S[8][1]; @@ -111,7 +113,6 @@ extern "C" { uint8_t buf[4 * BLAKE2B_BLOCKBYTES]; size_t buflen; } blake2bp_state; -#pragma pack(pop) // Streaming API int blake2s_init( blake2s_state *S, const uint8_t outlen );