Commit a5909bd1 authored by Mat Hostetter's avatar Mat Hostetter Committed by Facebook GitHub Bot

Work around spurious -Werror=array-bounds error in gcc-9.3.

Summary:
gcc-9.3 complains about folly::Format:

```
array subscript -1 is outside array bounds of ‘char [69]’
```

But the warning is incorrect; my guess is that it is confused because
it doesn't realize that higher-level logic guarantees that integer
formatting will run out of digits before it runs out of buffer.

Changing some code from `array + x` to `&array[x]` works around it.

Reviewed By: pixelb

Differential Revision: D20694399

fbshipit-source-id: 1176858054cdec9e415de4829371647958955103
parent cc9056ea
...@@ -569,7 +569,7 @@ class FormatValue< ...@@ -569,7 +569,7 @@ class FormatValue<
presentation, presentation,
"' specifier"); "' specifier");
valBufEnd = valBuf + valBufSize; valBufEnd = valBuf + valBufSize;
valBufBegin = valBuf + detail::uintToOctal(valBuf, valBufSize, uval); valBufBegin = &valBuf[detail::uintToOctal(valBuf, valBufSize, uval)];
if (arg.basePrefix) { if (arg.basePrefix) {
*--valBufBegin = '0'; *--valBufBegin = '0';
prefixLen = 1; prefixLen = 1;
...@@ -582,7 +582,7 @@ class FormatValue< ...@@ -582,7 +582,7 @@ class FormatValue<
presentation, presentation,
"' specifier"); "' specifier");
valBufEnd = valBuf + valBufSize; valBufEnd = valBuf + valBufSize;
valBufBegin = valBuf + detail::uintToHexLower(valBuf, valBufSize, uval); valBufBegin = &valBuf[detail::uintToHexLower(valBuf, valBufSize, uval)];
if (arg.basePrefix) { if (arg.basePrefix) {
*--valBufBegin = 'x'; *--valBufBegin = 'x';
*--valBufBegin = '0'; *--valBufBegin = '0';
...@@ -596,7 +596,7 @@ class FormatValue< ...@@ -596,7 +596,7 @@ class FormatValue<
presentation, presentation,
"' specifier"); "' specifier");
valBufEnd = valBuf + valBufSize; valBufEnd = valBuf + valBufSize;
valBufBegin = valBuf + detail::uintToHexUpper(valBuf, valBufSize, uval); valBufBegin = &valBuf[detail::uintToHexUpper(valBuf, valBufSize, uval)];
if (arg.basePrefix) { if (arg.basePrefix) {
*--valBufBegin = 'X'; *--valBufBegin = 'X';
*--valBufBegin = '0'; *--valBufBegin = '0';
...@@ -611,7 +611,7 @@ class FormatValue< ...@@ -611,7 +611,7 @@ class FormatValue<
presentation, presentation,
"' specifier"); "' specifier");
valBufEnd = valBuf + valBufSize; valBufEnd = valBuf + valBufSize;
valBufBegin = valBuf + detail::uintToBinary(valBuf, valBufSize, uval); valBufBegin = &valBuf[detail::uintToBinary(valBuf, valBufSize, uval)];
if (arg.basePrefix) { if (arg.basePrefix) {
*--valBufBegin = presentation; // 0b or 0B *--valBufBegin = presentation; // 0b or 0B
*--valBufBegin = '0'; *--valBufBegin = '0';
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment