[libcxx-commits] [libcxx] [libc++] Fix unnecessary flushes in std::print() on POSIX (PR #70321)
Nikolas Klauser via libcxx-commits
libcxx-commits at lists.llvm.org
Mon Mar 9 09:56:16 PDT 2026
================
@@ -59,43 +59,19 @@ scoped_test_env env;
std::string filename = env.create_file("output.txt");
static void test_basics() {
- FILE* file = std::fopen(filename.c_str(), "wb");
- assert(file);
-
- // Test writing to a "non-terminal" stream does not call WriteConsoleW.
- std::__print::__vprint_unicode_windows(file, "Hello", std::make_format_args(), false, false);
- assert(std::ftell(file) == 5);
-
// It's not possible to reliably test whether writing to a "terminal" stream
// flushes before writing. Testing flushing a closed stream worked on some
// platforms, but was unreliable.
calling = true;
- std::__print::__vprint_unicode_windows(file, " world", std::make_format_args(), false, true);
+ std::__print::__vprint_unicode_windows(stdout, " world", std::make_format_args(), false);
----------------
philnik777 wrote:
We should almost certainly not be using `stdout` here, since that's used by the test runner and we should avoid trashing that. Why did you change this test in general?
https://github.com/llvm/llvm-project/pull/70321
More information about the libcxx-commits
mailing list