From a2200bd01e7d607d0c2668f388b9b2587bf19319 Mon Sep 17 00:00:00 2001 From: Nekotekina Date: Sun, 5 Mar 2017 21:42:54 +0300 Subject: [PATCH] Speculative fix for fmt::format --- Utilities/StrFmt.cpp | 2 +- Utilities/StrFmt.h | 4 ++-- Utilities/cfmt.h | 2 +- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/Utilities/StrFmt.cpp b/Utilities/StrFmt.cpp index 7678041cd8..a8c77bcc3d 100644 --- a/Utilities/StrFmt.cpp +++ b/Utilities/StrFmt.cpp @@ -252,7 +252,7 @@ struct fmt::cfmt_src template T get(std::size_t index) const { - return reinterpret_cast(args[index]); + return *reinterpret_cast(reinterpret_cast(args + index)); } void skip(std::size_t extra) diff --git a/Utilities/StrFmt.h b/Utilities/StrFmt.h index 2b21a35abe..131aa7152a 100644 --- a/Utilities/StrFmt.h +++ b/Utilities/StrFmt.h @@ -60,9 +60,9 @@ struct fmt_unveil::value && sizeof using type = T; // Convert FP to f64 and reinterpret (TODO?) - static inline u64 get(f64 arg) + static inline u64 get(const f64 arg) { - return reinterpret_cast(arg); + return *reinterpret_cast(reinterpret_cast(&arg)); } }; diff --git a/Utilities/cfmt.h b/Utilities/cfmt.h index 05bd5c13bf..3fe0002d66 100644 --- a/Utilities/cfmt.h +++ b/Utilities/cfmt.h @@ -581,7 +581,7 @@ std::size_t cfmt_append(Dst& out, const Char* fmt, Src&& src) const std::string _fmt(fmt - ctx.size, fmt); - const u64 arg0 = src.template get(0); + const f64 arg0 = src.template get(0); const u64 arg1 = ctx.args >= 1 ? src.template get(1) : 0; const u64 arg2 = ctx.args >= 2 ? src.template get(2) : 0;