From 380d7d7e6b01f57784d42ea874add8a2daa4e6ef Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Vladim=C3=ADr=20Vondru=C5=A1?= Date: Sun, 8 Jun 2025 18:47:22 +0200 Subject: [PATCH] DebugTools: no need to use STL streams here anymore. Well, of course the obvious change hit some massive bug in MSVC's codegen, in all versions of that thing. Why am I even surprised. --- src/Magnum/DebugTools/FrameProfiler.cpp | 19 +++++++++++++------ 1 file changed, 13 insertions(+), 6 deletions(-) diff --git a/src/Magnum/DebugTools/FrameProfiler.cpp b/src/Magnum/DebugTools/FrameProfiler.cpp index 177a23aa3..b7c5411bd 100644 --- a/src/Magnum/DebugTools/FrameProfiler.cpp +++ b/src/Magnum/DebugTools/FrameProfiler.cpp @@ -27,13 +27,11 @@ #include "FrameProfiler.h" #include -#include #include #include #include #include #include -#include /** @todo drop once Debug is stream-free */ #include #include "Magnum/Math/Functions.h" @@ -383,10 +381,19 @@ void FrameProfiler::printStatisticsInternal(Debug& out) const { } Containers::String FrameProfiler::statistics() const { - std::ostringstream out; - Debug d{&out, Debug::Flag::NoNewlineAtTheEnd|Debug::Flag::DisableColors}; - printStatisticsInternal(d); - return out.str(); + Containers::String out; + /* While both GCC and Clang do the right thing here and call Debug + destructor before the String destructor, causing the printed contents to + be correctly flushed, MSVC doesn't, leading to the output being empty. + This only seems to be fixed with MSVC 2022 and /permissive-, without the + flag it's broken too. No idea what's going on, maybe it's some stupid + interaction of return value move elision and the other destructor or + whatever. Ugh. */ + { + Debug d{&out, Debug::Flag::NoNewlineAtTheEnd|Debug::Flag::DisableColors}; + printStatisticsInternal(d); + } + return out; } void FrameProfiler::printStatistics(const UnsignedInt frequency) const {