diff --git a/include/fmt/ostream.h b/include/fmt/ostream.h index b35725a3..b77bd9a7 100644 --- a/include/fmt/ostream.h +++ b/include/fmt/ostream.h @@ -93,8 +93,9 @@ inline bool write(std::wfilebuf&, fmt::basic_string_view) { // It is a separate function rather than a part of vprint to simplify testing. template void write_buffer(std::basic_ostream& os, buffer& buf) { - if (auto filebuf = dynamic_cast*>(os.rdbuf())) { - if (write(*filebuf, {buf.data(), buf.size()})) return; + if (FMT_MSC_VER) { + auto filebuf = dynamic_cast*>(os.rdbuf()); + if (filebuf && write(*filebuf, {buf.data(), buf.size()})) return; } const Char* buf_data = buf.data(); using unsigned_streamsize = std::make_unsigned::type;