Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions include/webcpp/hash/backends/bearssl.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -75,9 +75,9 @@
WEBCPP_HASH_DETAIL_BEARSSL_CONFIGURATION))
#endif

// A declaration: src/canary_bearssl.c defines it, constant, in /third_party//bearssl.
// NOLINTNEXTLINE(bugprone-dynamic-static-initializers)
extern "C" const char WEBCPP_HASH_DETAIL_BEARSSL_CANARY;
// A declaration: src/canary_bearssl.c defines it, constant, in /third_party//bearssl, so its
// initialisation is static, never dynamic; constinit, on this declaration, states it.
extern "C" constinit const char WEBCPP_HASH_DETAIL_BEARSSL_CANARY;

namespace webcpp::hash::backends {

Expand Down
6 changes: 3 additions & 3 deletions include/webcpp/hash/backends/botan.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -110,9 +110,9 @@
WEBCPP_HASH_DETAIL_MISMATCH_VALUE(botan, WEBCPP_HASH_BOTAN_COMMIT, configured))
#endif

// A declaration: src/canary_botan.cpp defines it, constant, in /third_party//botan.
// NOLINTNEXTLINE(bugprone-dynamic-static-initializers)
extern "C" const char WEBCPP_HASH_DETAIL_BOTAN_CANARY;
// A declaration: src/canary_botan.cpp defines it, constant, in /third_party//botan, so its
// initialisation is static, never dynamic; constinit, on this declaration, states it.
extern "C" constinit const char WEBCPP_HASH_DETAIL_BOTAN_CANARY;

namespace webcpp::hash {

Expand Down
6 changes: 3 additions & 3 deletions include/webcpp/hash/backends/sodium.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -109,9 +109,9 @@
WEBCPP_HASH_DETAIL_SODIUM_CONFIGURATION))
#endif

// A declaration: src/canary_sodium.c defines it, constant, in /third_party//sodium.
// NOLINTNEXTLINE(bugprone-dynamic-static-initializers)
extern "C" const char WEBCPP_HASH_DETAIL_SODIUM_CANARY;
// A declaration: src/canary_sodium.c defines it, constant, in /third_party//sodium, so its
// initialisation is static, never dynamic; constinit, on this declaration, states it.
extern "C" constinit const char WEBCPP_HASH_DETAIL_SODIUM_CANARY;

namespace webcpp::hash {

Expand Down
6 changes: 3 additions & 3 deletions include/webcpp/hash/blake3.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -63,9 +63,9 @@
WEBCPP_HASH_DETAIL_BLAKE3_CONFIGURATION))
#endif

// A declaration: src/canary_blake3.c defines it, constant, in /third_party//blake3.
// NOLINTNEXTLINE(bugprone-dynamic-static-initializers)
extern "C" const char WEBCPP_HASH_DETAIL_BLAKE3_CANARY;
// A declaration: src/canary_blake3.c defines it, constant, in /third_party//blake3, so its
// initialisation is static, never dynamic; constinit, on this declaration, states it.
extern "C" constinit const char WEBCPP_HASH_DETAIL_BLAKE3_CANARY;

namespace webcpp::hash {

Expand Down
14 changes: 14 additions & 0 deletions include/webcpp/hash/digest.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -734,6 +734,17 @@ template <class Digest, class Backend = default_backend<Digest>>
return hashed;
}

// MSVC's warning C4324 ("structure was padded due to alignment specifier") is off for the hasher
// alone. A backend's state may carry an alignment specifier (libsodium's are CRYPTO_ALIGN(16) or
// CRYPTO_ALIGN(64)), so the hasher is padded after its last member to a multiple of that
// alignment, as the state requires, and no order of the members avoids it: the padding is the
// intended layout. MSVC for ARM64 reports that trailing padding under /W4, which /WX makes an
// error; MSVC for x64 reports only padding before an aligned member, never after the last one,
// and so is silent here (14.3 and 14.5 alike, msvc-lane's probe of 2026-11-23).
#ifdef _MSC_VER
#pragma warning(push)
#pragma warning(disable : 4324)
#endif
/**
A hash fed in pieces, with one result: `make`, `update` as often as the data comes, then `finish`
once (spec 2.15).
Expand Down Expand Up @@ -924,6 +935,9 @@ class hasher {
bool keyed_ = false; // made with a key: update and finish hold the timing guard
phase phase_ = phase::spent;
};
#ifdef _MSC_VER
#pragma warning(pop)
#endif

} // namespace webcpp::hash

Expand Down
4 changes: 3 additions & 1 deletion include/webcpp/hash/keccak.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,9 @@
WEBCPP_HASH_DETAIL_XKCP_CONFIGURATION))
#endif

extern "C" const char WEBCPP_HASH_DETAIL_XKCP_CANARY;
// A declaration: src/canary_xkcp.c defines it, constant, in /third_party//xkcp, so its
// initialisation is static, never dynamic; constinit, on this declaration, states it.
extern "C" constinit const char WEBCPP_HASH_DETAIL_XKCP_CANARY;

namespace webcpp::hash::detail {

Expand Down
11 changes: 6 additions & 5 deletions src/canary_botan.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -38,8 +38,9 @@
WEBCPP_HASH_DETAIL_MISMATCH_VALUE(botan, WEBCPP_HASH_BOTAN_COMMIT, WEBCPP_HASH_BOTAN_BUILT))
#endif

// The canary, constant, with C's linkage, as backends/botan.hpp declares it.
extern "C" const char WEBCPP_HASH_DETAIL_CANARY(botan, WEBCPP_HASH_BOTAN_COMMIT,
WEBCPP_HASH_BOTAN_BUILT);
extern "C" const char WEBCPP_HASH_DETAIL_CANARY(botan, WEBCPP_HASH_BOTAN_COMMIT,
WEBCPP_HASH_BOTAN_BUILT) = 0;
// The canary, constant, with C's linkage, as backends/botan.hpp declares it: constinit there, so
// constinit here too, on the initialising declaration, as the standard asks.
extern "C" constinit const char WEBCPP_HASH_DETAIL_CANARY(botan, WEBCPP_HASH_BOTAN_COMMIT,
WEBCPP_HASH_BOTAN_BUILT);
extern "C" constinit const char WEBCPP_HASH_DETAIL_CANARY(botan, WEBCPP_HASH_BOTAN_COMMIT,
WEBCPP_HASH_BOTAN_BUILT) = 0;
Loading