Skip to content

xgameruntime_gamesave_test: build the save folder's path from char8_t, not the deprecated u8path (C4996) - #4931

Open
etcetera-yt wants to merge 1 commit into
ItsNotRexed:mainfrom
etcetera-yt:gamesave-test-u8path-cxx20
Open

etcetera-yt wants to merge 1 commit into
ItsNotRexed:mainfrom
etcetera-yt:gamesave-test-u8path-cxx20

Conversation

@etcetera-yt

Copy link
Copy Markdown
Contributor

Claimed in the coordination issue as: new BUILD item (claim).

What and why

runtime/test/xgameruntime_gamesave_test.cpp:293 (added in de67135) checks the save folder with std::filesystem::u8path(folder.c_str()). u8path is deprecated in C++20, so every MSVC build prints:

xgameruntime_gamesave_test.cpp(293,62): warning C4996: 'std::filesystem::u8path': warning STL4021: The std::filesystem::u8path() overloads are deprecated in C++20. ...

The path is now built from the same UTF-8 text as char8_t, the C++20 replacement, which decodes the same way. Test-only, one expression.

Tested

NVIDIA GeForce RTX 5060 Ti, driver 621.14, Windows 10 19045, MSVC (VS 2022 Build Tools), RelWithDebInfo, branch on main d974c88a.

  • Before: building xgameruntime_gamesave_test gives the C4996 above, and the test passes 50 checks with 0 failures.
  • After: the same build has 0 warnings, and the test passes 50 checks with 0 failures.
  • Same decoding: I ran the test with TMP/TEMP pointing at a folder named tmp_Ω東京 (outside this PC's code page 1252), so the save folder it checks is non-ASCII.
    • With this change: 50 checks, 0 failures.
    • Negative control, a plain std::filesystem::path(folder.c_str()), which decodes as the ANSI code page: FAIL FilesGetFolderWithUiResult returns a folder that exists, 1 failure, while it still passes with an ASCII TMP. That shows the non-ASCII folder was used and that the new form decodes UTF-8 as u8path did.
  • Baseline main d974c88a full build and ctest -j2: 167/170, with and without LEONIDA_VK_VALIDATION=1. The failures are root_signature_oracle (root_signature_oracle_test: Windows 10 can't serialize the heap-direct flags; check the other flags there #4731), d3d12_indirect_dispatch_count (d3d12_indirect_dispatch_count_test: check the layer against the expected count (WARP 22621 reuses a stale count) #4653) and d3d12_conservative_raster (TEST-907).
  • Full ctest on this branch, with and without validation: running now; I'll post it here.

Not tested: Linux. The file is built only on Windows, since it uses windows.h.

AI-assisted: yes (Claude Code).

Checklist

  • No game data, keys or decryption (CONTRIBUTING.md), including in logs or reports quoted here.
  • A new translator rule is in the contract table of docs/design.md, with how it was confirmed. (not a translator change)

🤖 Generated with Claude Code

https://claude.ai/code/session_01GZEZyXGTTXs4V33hrBw1tD

… instead of the deprecated u8path

std::filesystem::u8path is deprecated in C++20 (MSVC C4996 / STL4021), the only warning in this test since
de67135. Constructing the path from the UTF-8 text as char8_t is C++20's replacement and decodes the same way:
with a TMP folder named outside the ANSI code page, the test still passes, while a plain path(folder.c_str())
fails the folder check.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01GZEZyXGTTXs4V33hrBw1tD
@tupacfan04

Copy link
Copy Markdown
Contributor

Independent Windows/MSVC check at f8d87ba0 (base 3faac557), Windows 11, MSVC 19.51.36260.0, RelWithDebInfo. Test-only change; no GPU or game data.

  • Built xgameruntime_gamesave_test at base and head with the same -DBUILD_TESTING=ON Ninja configuration. Base emits warning C4996: 'std::filesystem::u8path' at runtime/test/xgameruntime_gamesave_test.cpp:293; head builds with no warning.
  • Clean sequential runs of both binaries: 50 checks, 0 failures, exit 0.
  • With TEMP/TMP pointing at a non-ASCII directory (tmp_Ω東京), the head binary also reports 50 checks, 0 failures, exit 0. The base binary passes there too (u8path already decoded UTF-8); this just confirms the char8_t form did not narrow the path through the ANSI code page.
  • The comment at the test names the C++20 replacement correctly: constructing std::filesystem::path from char8_t* has the same UTF-8 decoding as u8path.

One unrelated observation: the test still uses a fixed %TEMP%\leonida_gamesave_test root, so two copies run at the same time race and one can report four quota/commit failures. Sequential runs after deleting the root are clean. That is the issue #4919 addresses, not introduced here.

AI-assisted verification; no game data used.

@etcetera-yt

Copy link
Copy Markdown
Contributor Author

Full build and full ctest on this branch (f8d87ba0, on main d974c88a), RTX 5060 Ti, driver 621.14, Windows 10 19045, RelWithDebInfo, ctest -j2:

AI-assisted (Claude Code).

@tupacfan04

Copy link
Copy Markdown
Contributor

APPROVE. One file, runtime/test/xgameruntime_gamesave_test.cpp:293, 2+/1-.

MSVC 19.51 / Ninja RelWithDebInfo: xgameruntime_gamesave_test exits 0 with 0 warnings. Negative control on origin/main 3faac557 gives exactly warning C4996: 'std::filesystem::u8path' ... STL4021 at that line. The binary runs 50 checks, 0 failures with ASCII TMP and with TMP/TEMP=...\tmp_Ω東京; main also passes there (u8path decodes UTF-8 too), so the change only drops the deprecation. git merge-tree clean; no other u8path in the tree.

Not tested here: GPU, Linux (file is windows.h-only), other targets.

Approve. AI-assisted review, no game files.

@MatyEjsr

Copy link
Copy Markdown

Tested f8d87ba0 on NVIDIA GeForce RTX 3090 (Ampere, driver 32.0.16.1742 / 617.42), Windows 11 (10.0.26200), VS 2022 Build Tools (MSVC 19.44.35230.0, Ninja RelWithDebInfo), Windows SDK 10.0.26100.0, Vulkan SDK 1.4.363.0: pass.

  • Before (main 3faac557): building xgameruntime_gamesave_test.cpp emitted warning C4996: 'std::filesystem::u8path': warning STL4021 at line 293.
  • After (f8d87ba0): incremental scripts\build_runtime.ps1 build (12 actions) compiled xgameruntime_gamesave_test.cpp with 0 warnings, exit 0.
  • Targeted ctest -R ^(xgameruntime_gamesave|xgameruntime|xgameruntime_user|xgameruntime_store|xgameruntime_offline)$ (validation off): 5/5 pass (xgameruntime_gamesave: 50 checks, 0 failures, 0.02s).
  • Targeted ctest -R ^(vk_sync_validation|xgameruntime_gamesave)$ with LEONIDA_VK_VALIDATION=1 and VK_LOADER_LAYERS_DISABLE=~implicit~: 2/2 pass, vk_sync_validation confirmed active.
  • Full ctest (validation off, no game files): 168 passed, 9 skipped, 1 disabled (gameinput), 0 failed (149.3s).
  • Clean merge check against origin/main (3faac557): no conflicts (git merge-tree exit 0).

Code read of runtime/test/xgameruntime_gamesave_test.cpp looks clean: std::filesystem::path(reinterpret_cast<const char8_t*>(folder.c_str())) is the standard C++20 replacement for u8path on UTF-8 buffers.

AI-assisted.

@etcetera-yt

Copy link
Copy Markdown
Contributor Author

Thanks @tupacfan04 for the review and the MSVC 19.51 check, and @MatyEjsr for the RTX 3090 run. AI-assisted (Claude Code).

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.

3 participants