From: Orvid King Date: Thu, 8 Oct 2015 16:52:15 +0000 (-0700) Subject: Use alloca rather than C99 stack allocated arrays X-Git-Tag: deprecate-dynamic-initializer~347 X-Git-Url: http://plrg.eecs.uci.edu/git/?a=commitdiff_plain;h=1ccc20a4d7164f621706f1f759ffec3e1a7b12a5;p=folly.git Use alloca rather than C99 stack allocated arrays Summary: Because MSVC doesn't support the latter. Closes https://github.com/facebook/folly/pull/271 Reviewed By: @meyering, @fredemmott Differential Revision: D2283975 fb-gh-sync-id: d021f739ceead9998b8fedbbd95f22ec9fe949b2 --- diff --git a/folly/Format.cpp b/folly/Format.cpp index 0f67969c..64e2cae5 100644 --- a/folly/Format.cpp +++ b/folly/Format.cpp @@ -48,11 +48,11 @@ void FormatValue::formatHelper( } // 2+: for null terminator and optional sign shenanigans. - char buf[2 + std::max({ - (2 + DoubleToStringConverter::kMaxFixedDigitsBeforePoint + - DoubleToStringConverter::kMaxFixedDigitsAfterPoint), - (8 + DoubleToStringConverter::kMaxExponentialDigits), - (7 + DoubleToStringConverter::kMaxPrecisionDigits)})]; + char buf[2 + std::max( + 2 + DoubleToStringConverter::kMaxFixedDigitsBeforePoint + + DoubleToStringConverter::kMaxFixedDigitsAfterPoint, + std::max(8 + DoubleToStringConverter::kMaxExponentialDigits, + 7 + DoubleToStringConverter::kMaxPrecisionDigits))]; StringBuilder builder(buf + 1, static_cast (sizeof(buf) - 1)); char plusSign;