From 5fd8af76ee61acaf01d423672491b830f142ec51 Mon Sep 17 00:00:00 2001 From: Cyril SIX Date: Thu, 28 Aug 2025 19:09:30 +0200 Subject: [PATCH] log.hpp: fix lack of return when FMT_EXCEPTIONS is disabled When compiling with clang, the compiler warns about the lack of return statement in the non-void function fmt::format. This fixes it by returning a default error string. --- Source/utils/log.hpp | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/Source/utils/log.hpp b/Source/utils/log.hpp index 387658155..f50f2f129 100644 --- a/Source/utils/log.hpp +++ b/Source/utils/log.hpp @@ -52,13 +52,17 @@ std::string format(std::string_view fmt, Args &&...args) } FMT_CATCH(const fmt::format_error &e) { + std::string error; #if FMT_EXCEPTIONS - // e.what() is undefined if exceptions are disabled, so we wrap the whole block + // e.what() is undefined if exceptions are disabled, so we wrap it // with an `FMT_EXCEPTIONS` check. - std::string error = StrCat("Format error, fmt: ", fmt, " error: ", e.what()); + error = e.what(); +#else + error = "unknown (FMT_EXCEPTIONS disabled)"; +#endif + std::string fullError = StrCat("Format error, fmt: ", fmt, " error: ", error); SDL_LogCritical(SDL_LOG_CATEGORY_APPLICATION, "%s", error.c_str()); app_fatal(error); -#endif } }