Skip to content

[M0-CORE-05] Fix Windows CI: C4324 in pools_tests (alignas(16) padding is fatal under /WX) - #7

Merged
offdev merged 1 commit into
masterfrom
fix/windows-ci-c4324-pools-fixture
Sep 11, 2026
Merged

offdev merged 1 commit into
masterfrom
fix/windows-ci-c4324-pools-fixture

Conversation

@offdev

@offdev offdev commented Sep 11, 2026

Copy link
Copy Markdown
Owner

Problem

The windows-msvc job fails compiling tests/laige-core/pools_tests.cpp:

pools_tests.cpp(106,1): error C2220: the following warning is treated as an error
pools_tests.cpp(106,1): warning C4324: '...::Padded': structure was padded due to alignment specifier

MSVC C4324 fires when an alignment specifier pads the struct, and the engine policy (/W4 /WX, NFR-8.10) makes it fatal. The Padded fixture (float a; char b; + alignas(16)) reached its 16-byte size purely through that padding — natural member size is 8 B.

Fix

Restructure the fixture to four floats. The observable properties are unchanged:

  • sizeof(Padded) == 16 and alignof(Padded) == 16 exactly as before, so the ElementSlot stride the fixture pins (max(sizeof(T), alignof(T))) is unchanged;
  • the members now fill the struct, so alignas(16) contributes alignment without adding padding and C4324 cannot fire;
  • no warning suppression (CORE-010).

The fixture's purpose (an element with non-trivial alignment pinning the bytes accounting) is preserved; a comment now documents the C4324 constraint so the fixture is not accidentally shrunk again.

Validation

  • GCC build of laige-core_tests warning-clean (-Wall -Werror);
  • full shared executable: 135/135 tests pass, including PoolStats.AlignedElementsUseAlignedStride (bytesInUse == 16, bytesCapacity == 2·(16+9));
  • no other code references the fixture; no include-graph or dependency impact.

…g 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.
@offdev
offdev merged commit ba4ffb2 into master Sep 11, 2026
8 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant