Repository navigation
ltc: command-line parsing under the MSVC nesting limit (Windows build) - #2361
Merged
Merged
Conversation
MSVC stops at src/c2pool/main_ltc.cpp(1940,17) with C1061 (blocks nested too deeply; limit 128): the argument loop in main() was one if/else-if chain of 119 branches, 118 else-ifs, nesting 126 at the positional branch. main_ltc.cpp: each flag is an independent if inside the loop. 113 branches end in continue, 5 end in return as before (--help/-h, --dump-doge-schedule-anchors, --utxo-digest, --utxo-stats, --ltc-utxo-stats). Checks run in the same order; the unknown-argument check and the positional branch stay last. Longest else-if chain in main() now 3, deepest nesting 23. Against master, the C++ tokens differ only by the 118 removed else and the 113 added continue. Behaviour check: master and this tree built with one identical dump of every local the loop writes, printed right after the loop. 302 argv cases (each of the 139 flag spellings once, with a value where it takes one; each value flag with its value missing at the end of argv; unknown flags; positional arguments; order, repeats and bad values; all flags at once): 302 of 302 give the same exit code, stdout and stderr. --help output is identical. test_settings_cli_scan ALL PASS; ci/check_param_catalog.py PASSED (453 main flag spellings, 441 catalog aliases).
The argument chain in main_v37_xmr.cpp main() had 92 else-ifs (MSVC
C1061 limit 128). It is split before --relay-listen into two chains of
42 and 49: the first ends in else flag_matched = false, and a match there
is recorded and moves to the next argument; the second keeps the
unknown-option and unexpected-argument errors and the record() after it.
Same flags in the same order, same recorded flags, errors and exit codes.
Against master, the C++ tokens differ only by the added flag_matched
declaration and the else flag_matched = false; if (flag_matched)
{ record(); continue; } between the two chains. v37_xmr_cli_strict_kat
gives the same result for all 1622 rows on master's binary and this one.
Reverts 9432722. main_v37_xmr.cpp's longest else-if chain is 92, below the MSVC nesting limit; its split goes through the XMR lane separately. This change then touches src/c2pool/main_ltc.cpp only.
frstrtr
added a commit
that referenced
this pull request
Nov 28, 2026
One commit, src/core/http_session.cpp only. Responses are unchanged. - **Why.** `HttpSession::process_request` matched its REST routes with one else-if chain of 87 branches (nesting 111). MSVC stops at about 128 nested blocks (C1061, as in #2361), so about 17 more routes would have broken the Windows build. - **Change.** The chain is split into four chains (27, 27, 25 and 9 branches), joined by a `route_matched` flag, the pattern `main_dash.cpp` uses. - Most branches set `rest_result` / `response_body` and fall through to the shared response code after the chain, so the split keeps that code path as it was. - The fourth chain keeps the original final else: admin, explorer, static files, 404 and the getinfo fallback. - Route order, conditions, the guards before the chain and the code after it are unchanged. A token diff against master (comments excluded) adds only the `route_matched` tokens and three braces. - **After:** longest else-if chain 26; deepest nesting in `process_request` 37. ## Checks (Release) - **Old vs new responses**, compared byte for byte by a temporary harness (not committed) on three local servers: every function wired, nothing wired, and token/CORS/not-ready. - Requests: every route on the web and stratum ports with GET and HEAD, prefix, bad-parameter, unknown, static and traversal variants, X-Forwarded-For, token and If-None-Match cases, other methods, and POST bodies. - **3624 requests:** 3602 byte-identical; the other 22 differ only in time fields (`timestamp`, `computed_at`, `ts`, `started`). They are identical once those fields are masked, and two runs of the old binary differ in exactly the same 22. - core_test HTTP/web/stratum-HTTP suites: 278 passed on both binaries; full core_test 870 passed.
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.
Command-line behaviour is unchanged. Net change: src/c2pool/main_ltc.cpp only.
src/c2pool/main_ltc.cpp(1940,17): error C1061: compiler limit: blocks nested too deeply(runs 46049548931 on 8e5b129 and 46071785930 on 902c42e). The LTC argument loop was one else-if chain of 119 branches (nesting 126 against MSVC's 128).ltc: command-line parsing as independent checks (MSVC nesting limit) (315d5d7)
if. 113 branches end incontinue;, and the 5 that returned before still return.elseand the 113 addedcontinue;.main(): 23 (was 126).v37-xmr: unchanged here (1dad4f1 reverts 9432722)
main_v37_xmr.cpp's longest chain is 92, below the limit; its split goes through the XMR lane as a separate change.Longest else-if chain per main, after this change
ltc 3, v37_xmr 92 (unchanged), dash 59 (already split), xmr_native_node 47, dgb 41, bch 36, btc 32, bip110 26, v37_btc_dash 14, v37 4.
Checks
c2pool-ltc --helpis byte-identical to master.ci/check_param_catalog.pyPASSED.Canon: none (command-line parse restructure of main_ltc.cpp; no consensus, payout or share-format change)