fmtlib / fmt

A modern formatting library
https://fmt.dev
Other
20.86k stars 2.51k forks source link

buffer flush issue on glibc FILE #4229

Closed emmanuelthome closed 2 weeks ago

emmanuelthome commented 3 weeks ago

Hi

The following code produces wrong output on the current master (720da57b): https://godbolt.org/z/x53n1KhcM. I tried g++-14, clang-16, clang-20. Linux current debian testing, glibc 2.40-3 (this happens on the current debian:testing docker image)

When the underlying FILE gets flushed, there's data from the existing buffer that gets printed again. E.g. the output is:

$ clang++ -I include  mytest.cpp src/format.cc src/os.cc && ./a.out
5393 defgh493

The problem disappears if I set FMT_USE_FALLBACK_FILE to 1.

vitaut commented 2 weeks ago

Fixed in https://github.com/fmtlib/fmt/commit/a35389b3c238208f979be7ea81d81ada807d3cd0, thanks for reporting.