tests/infra: move to C++23 (std pins, g++-14 in CI, deducing this in test code)#228
Merged
Conversation
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.
Moves the test/CI infrastructure from C++20 to C++23 and converts the recursive lambdas in test code to deducing
this. Companion PR for the library conversion follows separately (#229, stacked on this one).Why now
The 2025 Southeast USA regional judges on Kattis with
g++-14 -O2 -std=gnu++23, and the SER contestant image ships g++ 14.2.0 — so our target contest environment is already C++23. Pinning the repo to the same standard means the hackpack is validated under the flags it will actually be compiled with.Infrastructure changes
Every
-std=c++20pin bumped to-std=c++23:.verify-helper/config.toml(verifier)tests/.config/.gcc_compile_flags(compile_gcc)tests/scripts/compile_clang.sh,clangtidy.sh,grep_clangformat_cppcheck.sh(cppcheck--std),compile_commented_snippets.shtests/Makefilehelp texttests/.config/.clang-format:Standard: c++20→Standard: Latest(clang-format has noc++23enum value;Latesttracks the newest standard it knows)CI toolchain:
ubuntu-latestdefaults to g++ 13.3, which has incomplete C++23 library support (no<generator>). The workflow now installs g++-14 and selects it viaupdate-alternativesin:library_checker_aizujob (verifier uses plaing++)compile_gccjob.github/actions/setup/action.yml(used by build_pdf → compile_commented_snippets, and the clang jobs' setup)clang jobs already run clang-22, which is fully C++23-capable — flag bump only.
Test-code changes: deducing
this(17 lambdas, 12 files)Recursive lambdas in
tests/library_checker_aizu_tests/converted from the pass-self-explicitly idiom to C++23 deducingthis:Justification: strictly shorter (drops the self parameter and the doubled argument at every call site), removes the most confusing idiom in the codebase, and avoids any chance of passing the wrong callable. No semantic change.
Files:
cd_asserts.hpp,edge_cd_asserts.hpp,data_structures/permutation_tree,dsu/kruskal_tree_aizu,graphs/dijkstra_lib_checker,handmade_tests/{count_paths, dsu, seg_tree_midpoint},trees/{edge_cd_count_paths_per_length, edge_cd_reroot_dp, shallowest_aizu_tree_height, shallowest_lib_checker_tree_path_composite}.Not converted (GCC bug): the 4 lambdas in
handmade_tests/functional_graph.test.cppandtrees/edge_cd_contour_range_{query,update}.test.cpplive inside struct constructors and access data members through the capturedthis. GCC 14/15 rejects member access inside a deducing-this lambda that captures the enclosingthis(GCC PR113563, fixed in GCC 16) — CI's g++-14 fails on them, so they keep the pass-self idiom until the toolchain moves past the bug.Validation
.test.cppfiles compile clean withg++ -std=c++23 -O2 -Wall -Wextraclang-format --dry-run --Werrorpasses over the entire library + tests with the updated configNote
World Finals is still documented as gnu++20 (though the WF25 Kattis mirror already used gnu++23). If the team advances, re-check that year's WF environment before relying on C++23-only features.