Skip to content

Commit 2631d55

Browse files
committed
Merge #11573: [Util] Update tinyformat.h
60b98f8 [Util] Update tinyformat.h (fanquake) Pull request description: Updates `tinyformat.h` to commit c42f/tinyformat@689695c upstream. Including: c42f/tinyformat@8a2812d c42f/tinyformat@5d9e05a c42f/tinyformat@48e2e48 @achow101 mentioned that since upgrading to Ubuntu 17.10 (GCC 7), tinyformat had been throwing lots of -Wimplicit-fallthrough warnings. However fallthrough warnings should have been silenced by #10489. cc @theuni. The upstream commit to fix fallthrough warnings is in this PR c42f/tinyformat#39. The last time tinyformat.h was updated in this repo was in #8274. Tree-SHA512: a51bd30544693550e08148daf5d244e3a3a410caff7897351eb9cd28f661dc85e193e045bb86068ee4006b2f89a7233b7573b8c50d93d2a9a15a11386fdcc605
2 parents e8f3c88 + 60b98f8 commit 2631d55

File tree

1 file changed

+13
-1
lines changed

1 file changed

+13
-1
lines changed

src/tinyformat.h

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -495,7 +495,11 @@ namespace detail {
495495
class FormatArg
496496
{
497497
public:
498-
FormatArg() {}
498+
FormatArg()
499+
: m_value(nullptr),
500+
m_formatImpl(nullptr),
501+
m_toIntImpl(nullptr)
502+
{ }
499503

500504
template<typename T>
501505
explicit FormatArg(const T& value)
@@ -507,11 +511,15 @@ class FormatArg
507511
void format(std::ostream& out, const char* fmtBegin,
508512
const char* fmtEnd, int ntrunc) const
509513
{
514+
assert(m_value);
515+
assert(m_formatImpl);
510516
m_formatImpl(out, fmtBegin, fmtEnd, ntrunc, m_value);
511517
}
512518

513519
int toInt() const
514520
{
521+
assert(m_value);
522+
assert(m_toIntImpl);
515523
return m_toIntImpl(m_value);
516524
}
517525

@@ -712,23 +720,27 @@ inline const char* streamStateFromFormat(std::ostream& out, bool& spacePadPositi
712720
break;
713721
case 'X':
714722
out.setf(std::ios::uppercase);
723+
// Falls through
715724
case 'x': case 'p':
716725
out.setf(std::ios::hex, std::ios::basefield);
717726
intConversion = true;
718727
break;
719728
case 'E':
720729
out.setf(std::ios::uppercase);
730+
// Falls through
721731
case 'e':
722732
out.setf(std::ios::scientific, std::ios::floatfield);
723733
out.setf(std::ios::dec, std::ios::basefield);
724734
break;
725735
case 'F':
726736
out.setf(std::ios::uppercase);
737+
// Falls through
727738
case 'f':
728739
out.setf(std::ios::fixed, std::ios::floatfield);
729740
break;
730741
case 'G':
731742
out.setf(std::ios::uppercase);
743+
// Falls through
732744
case 'g':
733745
out.setf(std::ios::dec, std::ios::basefield);
734746
// As in boost::format, let stream decide float format.

0 commit comments

Comments
 (0)