Speculative fix for fmt::format

This commit is contained in:
Nekotekina 2017-03-05 21:42:54 +03:00
parent 9a9455a696
commit a2200bd01e
3 changed files with 4 additions and 4 deletions

View File

@ -252,7 +252,7 @@ struct fmt::cfmt_src
template <typename T>
T get(std::size_t index) const
{
return reinterpret_cast<const T&>(args[index]);
return *reinterpret_cast<const T*>(reinterpret_cast<const u8*>(args + index));
}
void skip(std::size_t extra)

View File

@ -60,9 +60,9 @@ struct fmt_unveil<T, std::enable_if_t<std::is_floating_point<T>::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<u64&>(arg);
return *reinterpret_cast<const u64*>(reinterpret_cast<const u8*>(&arg));
}
};

View File

@ -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<u64>(0);
const f64 arg0 = src.template get<f64>(0);
const u64 arg1 = ctx.args >= 1 ? src.template get<u64>(1) : 0;
const u64 arg2 = ctx.args >= 2 ? src.template get<u64>(2) : 0;