Repository navigation
hash: MSVC ARM64's C4324 off for the hasher, and the canaries declared constinit - #12
Merged
Merged
Conversation
added 2 commits
November 23, 2026 06:24
…g padding an aligned backend state needs is its intended layout libsodium's states are CRYPTO_ALIGN(16) or CRYPTO_ALIGN(64), so hasher<Digest, backends::sodium> is padded after its last member to that alignment, and no order of the members avoids it. MSVC for ARM64 reports that trailing padding as C4324 under /W4, which /WX makes an error, and stopped 14 tests (xof_sodium, digests_sodium, blake2b_sodium, capabilities, capabilities_botan, agreement_families, agreement_families_botan, allocation and their no-exceptions twins). MSVC for x64 reports only padding before an aligned member, never after the last one: a probe on the Windows VM, 14.3 and 14.5, gave both architectures the same layouts (448 bytes, alignment 64) and warned on ARM64 alone. The push and pop around the class template silence its instantiations and nothing else.
…ynamic-static-initializers reads, in place of four suppressions Each canary's declaration (BLAKE3, Botan, BearSSL, libsodium, and XKCP's, which carried no suppression) is a namespace-scope variable without an initialiser, which the check reports in a header as one that may be dynamically initialised. Its definition is a constant, so its initialisation is static; constinit on the declaration states it, as webcpp::crypto's canaries do (crypto 46a0df6). src/canary_botan.cpp, the one definition in C++, repeats constinit on its initialising declaration, as the standard asks.
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.
Two small fixes of webcpp::hash.
digest.hpp: the hasher turns MSVC's C4324 off for itself (push/pop around the class template). libsodium's states areCRYPTO_ALIGN(16)orCRYPTO_ALIGN(64), sohasher<Digest, backends::sodium>is padded after its last member to that alignment, which no member order avoids. MSVC for ARM64 reports that trailing padding under /W4 (an error under /WX) and stopped 14 tests (xof_sodium, digests_sodium, blake2b_sodium, capabilities, capabilities_botan, agreement_families, agreement_families_botan, allocation, and their no-exceptions twins). MSVC for x64 reports only padding before an aligned member, never after the last one: a probe on the Windows VM gave both architectures the same layouts (448 bytes, alignment 64) and warned on ARM64 alone, on 14.3 and 14.5.constinit, which clang-tidy's bugprone-dynamic-static-initializers reads, in place of four NOLINT suppressions, as webcpp::crypto's canaries are (crypto 46a0df6);src/canary_botan.cpp, the one C++ definition, repeatsconstinit.Verified locally: native clang, gcc and Emscripten lanes (
b2 -a libs/hash/test libs/hash/example), MSVC 14.3 and 14.5 on ARM64 (msvc-lane, with hash's and crypto's tests), the Linux lint (full) and the macOS lint.