The code in BerkeleyRODatabase::Backup() relies on copy_file() with overwrite_existing working.
Upstream fixes:
- https://github.com/gcc-mirror/gcc/commit/017e3f89b081e4828a588a3bd27b5feacea042b7
- https://github.com/gcc-mirror/gcc/commit/35c98149a5c7af9159fa7615d8d827b3aaa3cc97
- https://github.com/gcc-mirror/gcc/commit/8b3e47b4099f319e38d357f7c646f51040a13d6e
Suggested in #36271 (comment).
Here is an example of the failure when cross-compiling for Windows using GCC 14.2.0:
./test/fs_tests.cpp(145): Entering test case "copy_file_overwrite_existing"
unknown location(0): fatal error: in "fs_tests/copy_file_overwrite_existing": std::filesystem::__cxx11::filesystem_error: filesystem error: cannot copy file: File exists [C:\Users\RUNNER~1\AppData\Local\Temp\test_common bitcoin\fs_tests\copy_file_overwrite_existing\c72b38273c1f6fce4336\a] [C:\Users\RUNNER~1\AppData\Local\Temp\test_common bitcoin\fs_tests\copy_file_overwrite_existing\c72b38273c1f6fce4336\b]
./test/fs_tests.cpp(155): last checkpoint