From 62af25dca8e589cd604d33f93a61d185fb223473 Mon Sep 17 00:00:00 2001 From: Victor Zverovich Date: Thu, 16 Nov 2017 08:09:12 -0800 Subject: [PATCH] Workaround yet another MSVC internal error --- include/fmt/format.h | 9 +++++---- test/format-test.cc | 5 +++-- 2 files changed, 8 insertions(+), 6 deletions(-) diff --git a/include/fmt/format.h b/include/fmt/format.h index f0a39ad2..ed9ebb7d 100644 --- a/include/fmt/format.h +++ b/include/fmt/format.h @@ -819,7 +819,7 @@ class null_terminating_iterator { return result; } - null_terminating_iterator operator--() { + constexpr null_terminating_iterator operator--() { --ptr_; return *this; } @@ -828,16 +828,16 @@ class null_terminating_iterator { return null_terminating_iterator(ptr_ + n, end_); } - null_terminating_iterator operator-(difference_type n) { + constexpr null_terminating_iterator operator-(difference_type n) { return null_terminating_iterator(ptr_ - n, end_); } - null_terminating_iterator operator+=(difference_type n) { + constexpr null_terminating_iterator operator+=(difference_type n) { ptr_ += n; return *this; } - difference_type operator-(null_terminating_iterator other) const { + constexpr difference_type operator-(null_terminating_iterator other) const { return ptr_ - other.ptr_; } @@ -3573,6 +3573,7 @@ inline typename std::enable_if< constexpr bool invalid_format = internal::check_format_string( string_view(format_str.value(), format_str.size())); + (void)invalid_format; return vformat(format_str.value(), make_args(args...)); } diff --git a/test/format-test.cc b/test/format-test.cc index 229a846c..55dd8832 100644 --- a/test/format-test.cc +++ b/test/format-test.cc @@ -1870,16 +1870,17 @@ TEST(FormatTest, FormatStringErrors) { // This causes an internal compiler error in MSVC2017. EXPECT_ERROR("{0:=5", "unknown format specifier", char); EXPECT_ERROR("{:{<}", "invalid fill character '{'", int); + EXPECT_ERROR("{:10000000000}", "number is too big", int); + EXPECT_ERROR("{:.10000000000}", "number is too big", int); #endif EXPECT_ERROR("{foo", "missing '}' in format string", int); EXPECT_ERROR("{10000000000}", "number is too big"); EXPECT_ERROR("{0x}", "invalid format string"); EXPECT_ERROR("{-}", "invalid format string"); EXPECT_ERROR("{1}", "argument index out of range", int); - EXPECT_ERROR("{:10000000000}", "number is too big", int); EXPECT_ERROR("{:{0x}}", "invalid format string", int); EXPECT_ERROR("{:{-}}", "invalid format string", int); - EXPECT_ERROR("{:.10000000000}", "number is too big", int); EXPECT_ERROR("{:.{0x}}", "invalid format string", int); EXPECT_ERROR("{:.{-}}", "invalid format string", int); + EXPECT_ERROR("{:.x}", "missing precision specifier", int); }