[M0-CORE-05] Fix Windows CI: C4324 in pools_tests (alignas(16) padding is fatal under /WX) - #7
Merged
Merged
Conversation
…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.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
The windows-msvc job fails compiling
tests/laige-core/pools_tests.cpp:MSVC C4324 fires when an alignment specifier pads the struct, and the engine policy (
/W4 /WX, NFR-8.10) makes it fatal. ThePaddedfixture (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) == 16andalignof(Padded) == 16exactly as before, so the ElementSlot stride the fixture pins (max(sizeof(T), alignof(T))) is unchanged;alignas(16)contributes alignment without adding padding and C4324 cannot fire;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
laige-core_testswarning-clean (-Wall -Werror);PoolStats.AlignedElementsUseAlignedStride(bytesInUse == 16, bytesCapacity == 2·(16+9));