Fix formatting of bool with FMT_COMPILE and add more tests

This commit is contained in:
Victor Zverovich
2020-06-14 07:16:50 -07:00
parent e956a14e9e
commit d702a68df2
2 changed files with 10 additions and 2 deletions

View File

@@ -3380,7 +3380,8 @@ inline std::string to_string(const T& value) {
}
template <typename T, FMT_ENABLE_IF(std::is_integral<T>::value)>
inline std::string to_string(T value) {
char buffer[detail::digits10<T>() + 2];
// Buffer should be large enough to store the number or "false" (for bool).
char buffer[(std::max)(detail::digits10<T>() + 2, 5)];
char* begin = buffer;
char* end = detail::write<char>(begin, value);
return std::string(begin, end);