Workaround yet another MSVC internal error

This commit is contained in:
Victor Zverovich 2017-11-16 08:09:12 -08:00
parent 594bd8feba
commit 62af25dca8
2 changed files with 8 additions and 6 deletions

View File

@ -819,7 +819,7 @@ class null_terminating_iterator {
return result; return result;
} }
null_terminating_iterator operator--() { constexpr null_terminating_iterator operator--() {
--ptr_; --ptr_;
return *this; return *this;
} }
@ -828,16 +828,16 @@ class null_terminating_iterator {
return null_terminating_iterator(ptr_ + n, end_); 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_); return null_terminating_iterator(ptr_ - n, end_);
} }
null_terminating_iterator operator+=(difference_type n) { constexpr null_terminating_iterator operator+=(difference_type n) {
ptr_ += n; ptr_ += n;
return *this; return *this;
} }
difference_type operator-(null_terminating_iterator other) const { constexpr difference_type operator-(null_terminating_iterator other) const {
return ptr_ - other.ptr_; return ptr_ - other.ptr_;
} }
@ -3573,6 +3573,7 @@ inline typename std::enable_if<
constexpr bool invalid_format = constexpr bool invalid_format =
internal::check_format_string<char, internal::error_handler, Args...>( internal::check_format_string<char, internal::error_handler, Args...>(
string_view(format_str.value(), format_str.size())); string_view(format_str.value(), format_str.size()));
(void)invalid_format;
return vformat(format_str.value(), make_args(args...)); return vformat(format_str.value(), make_args(args...));
} }

View File

@ -1870,16 +1870,17 @@ TEST(FormatTest, FormatStringErrors) {
// This causes an internal compiler error in MSVC2017. // This causes an internal compiler error in MSVC2017.
EXPECT_ERROR("{0:=5", "unknown format specifier", char); EXPECT_ERROR("{0:=5", "unknown format specifier", char);
EXPECT_ERROR("{:{<}", "invalid fill character '{'", int); EXPECT_ERROR("{:{<}", "invalid fill character '{'", int);
EXPECT_ERROR("{:10000000000}", "number is too big", int);
EXPECT_ERROR("{:.10000000000}", "number is too big", int);
#endif #endif
EXPECT_ERROR("{foo", "missing '}' in format string", int); EXPECT_ERROR("{foo", "missing '}' in format string", int);
EXPECT_ERROR("{10000000000}", "number is too big"); EXPECT_ERROR("{10000000000}", "number is too big");
EXPECT_ERROR("{0x}", "invalid format string"); EXPECT_ERROR("{0x}", "invalid format string");
EXPECT_ERROR("{-}", "invalid format string"); EXPECT_ERROR("{-}", "invalid format string");
EXPECT_ERROR("{1}", "argument index out of range", int); 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("{:{0x}}", "invalid format string", int);
EXPECT_ERROR("{:{-}}", "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("{:.{0x}}", "invalid format string", int);
EXPECT_ERROR("{:.{-}}", "invalid format string", int); EXPECT_ERROR("{:.{-}}", "invalid format string", int);
EXPECT_ERROR("{:.x}", "missing precision specifier", int);
} }