cauchy1988 opened a new pull request, #2406:
URL: https://github.com/apache/incubator-pegasus/pull/2406
## Problem
Building tests (`-DBUILD_TEST=ON`) with **GCC 13** fails with:
```
src/server/test/pegasus_server_test_base.h:98:29: error: array subscript 1
is outside array bounds of 'void [8]' [-Werror=array-bounds=]
98 | argv[idx++] = const_cast<char *>(kv.first.c_str());
```
This affects every test file that includes `pegasus_server_test_base.h` (12+
test files).
## Root Cause
GCC 13 introduced stricter `-Warray-bounds` static analysis with aggressive
inlining. The chain of events:
1. `start()` calls `start({})` — passing an empty `std::map`
2. GCC inlines `start(const map&)` into `start()`
3. With an empty map: `make_unique<char*[]>(1 + 0 * 2)` allocates space for
**1** pointer
4. The compiler sees the loop body `argv[idx++] = ...` and determines that
accessing `argv[1]` (or beyond) would be out-of-bounds for the allocated array
5. Even though the loop body never executes (empty map), GCC 13's static
analysis flags the potential out-of-bounds access
6. Since Pegasus builds with `-Werror`, this becomes a **hard build failure**
Note: older GCC versions (and possibly Clang) don't trigger this warning,
which is why community CI passes.
## Fix
Replace `std::make_unique<char*[]>` with `std::vector<char*>`:
- `vector::push_back` doesn't trigger the same static analysis false positive
- Also adds a `nullptr` sentinel at the end of argv (good practice for
C-style argv arrays)
- Adds `#include <vector>`
## Testing
- Full build with `-DBUILD_TEST=ON` passes on GCC 13.3 (Ubuntu 24.04 ARM64)
- `base_api_test` runs successfully
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]