errors: do not construct streams between "sysop" and "get last system error"
Constructing a stream may involve system operations between the last call and asking for the last error.
Reported on Discourse: https://discourse.cmake.org/t/copy-dll-to-target-path-randomly-got-file-copy-cannot-set-permissions-on-but-break-my-build-pipeline/9539
Backport: release