From 56f5765d09ad0b26e779cf4f1e59c4df62312bb5 Mon Sep 17 00:00:00 2001 From: Pascal Severin Date: Fri, 11 Sep 2026 18:33:51 +0200 Subject: [PATCH] [M0-CORE-05] Fix Windows CI: C4324 in pools_tests (alignas(16) padding is fatal under /WX) MSVC C4324 ("structure was padded due to alignment specifier") fires when an alignment specifier pads the struct, and the engine policy's /WX (NFR-8.10) turns it into error C2220 in the windows-msvc job. The Padded test fixture (float a; char b; + alignas(16)) reached its 16-byte size purely through that padding. Restructure the fixture to four floats: sizeof(Padded) == 16 and alignof(Padded) == 16 exactly as before, but the members now fill the struct, so alignas(16) contributes alignment without adding padding and C4324 cannot fire. The ElementSlot stride the fixture pins (max(sizeof(T), alignof(T))) is unchanged; the pools suite (135/135 tests in the shared executable) passes unchanged, including PoolStats.AlignedElementsUseAlignedStride. --- tests/laige-core/pools_tests.cpp | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/tests/laige-core/pools_tests.cpp b/tests/laige-core/pools_tests.cpp index 6389ca7..2bc76ed 100644 --- a/tests/laige-core/pools_tests.cpp +++ b/tests/laige-core/pools_tests.cpp @@ -99,10 +99,18 @@ class Tracked { }; // An element with non-trivial alignment: pins the ElementSlot stride -// (max(sizeof(T), alignof(T))) in the bytes accounting. +// (max(sizeof(T), alignof(T))) in the bytes accounting. The four floats +// fill exactly 16 bytes, so alignas(16) contributes alignment without +// adding padding: MSVC C4324 ("structure was padded due to alignment +// specifier") fires only when the alignment specifier pads the struct +// and is fatal under the engine's /W4 /WX (NFR-8.10, Windows CI job). +// A shorter member list (e.g. float + char) re-introduces that padding +// and breaks the Windows build. struct alignas(16) Padded { float a{}; - char b{}; + float b{}; + float c{}; + float d{}; }; } // namespace @@ -534,7 +542,8 @@ TEST(PoolStats, AlignedElementsUseAlignedStride) { Tracked::resetCounters(); laige::Pool pool(laige::Pool::Options{2}); ASSERT_TRUE(pool.create().ok()); - // sizeof(Padded) == 16 (alignas(16)); the slot stride matches. + // sizeof(Padded) == 16, alignof(Padded) == 16 (alignas(16)); the slot + // stride matches. EXPECT_EQ(pool.stats().bytesInUse, 16u); EXPECT_EQ(pool.stats().bytesCapacity, 2u * (16u + 9u)); EXPECT_EQ(pool.at(pool.create().value()).a, 0.0f);