Skip to content

hash: two-word locals and parameters in the headers (MSVC C4459 in a user's program), and the user_globals test - #16

Merged
pinhopro merged 7 commits into
mainfrom
hash/user-globals
Nov 26, 2026
Merged

pinhopro merged 7 commits into
mainfrom
hash/user-globals

Conversation

@pinhopro

Copy link
Copy Markdown
Contributor

MSVC's C4459 ("declaration of 'x' hides global declaration"), an error at /W4 /WX, stopped a user's program that has a global named like a one-word local or parameter of a hash header's function (inline functions always; function templates at their locals when instantiated). Secure's stream found and fixed the same defect in its own headers (its D3).

  • test/user_globals_test.cpp: a global of every one-word name a header gave a local or a parameter (119, from clang's AST in every configuration: with and without exceptions and threads, the test seams, Emscripten), after every other library's headers and before every hash header, then a call of every cell of every backend and every asynchronous function, which instantiates the templates. Before the fix it failed on MSVC 14.3 x64 debug with 1,001 C4459 errors over 85 names in 20 headers.
  • Every one-word local and parameter of a C++ function in include/ now has two spelled-out words, role then kind (917 declarations, renamed from the AST's declarations and references; the asynchronous machinery as crypto's detail/heavy.hpp names it). The doc comments, the engines' interface sketches, doc/async.adoc and AGENTS.md follow.
  • Kept: HKDF's public functions keep salt, as the change hkdf-pieces' spec requires; a function template's parameter raises no C4459. The XKCP adapter's C declarations keep src/xkcp_adapter.c's names, since a declaration without a body raises none.
  • Parameter names are not API: no caller changes.

Verified locally: MSVC 14.3 and 14.5 x64 debug (hash's tests and examples), MSVC 14.5 arm64 (the timing tests), clang, gcc-15, wasip2, wasip3 and Emscripten, b2 libs/hash/doc, macOS clang-tidy and the Linux lint.

R added 7 commits November 26, 2026 06:27
…local or a parameter, before every public header and a call of every cell, which MSVC's C4459 reports at /W4 /WX
…s (917 declarations of 119 one-word names, which MSVC's C4459 reports in a program with a global of one), the doc comments, kdfs.adoc and AGENTS.md with them; user_globals calls async_pbkdf2 only with threads
…ed, the options const, no key derivation calls on a backend without one, lambdas without an empty parameter list
…e hkdf-pieces' spec names it (a function template's parameter raises no C4459); the kdfs page with them; libsodium's whole-digest test is writes_whole_digest
…es and the guide quote the new parameter names; OpenSSL's SSKDF and X9.63 engines take fixed_info and shared_info as the public functions do; every @PARAM starts its line and the paragraphs the longer names left short are rewrapped; AGENTS.md cites a real guard and states HKDF's salt
@pinhopro
pinhopro merged commit d4d0119 into main Nov 26, 2026
1 of 3 checks passed
@pinhopro
pinhopro deleted the hash/user-globals branch November 26, 2026 11:08
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