Commit 437f52e
Avoid GCC 16 -Wstringop-overflow false positive in NxsString
GCC 16.1's tightened -Wstringop-overflow analysis flags a
__builtin_memmove "writing into a region of size 0" inlined from
std::char_traits<char>::copy, triggered by the append(std::string(...))
pattern in NxsString::operator+= (reported by CRAN gcc-SAN checks).
Rewrite the two suspect overloads to avoid constructing a temporary
std::string before appending:
- operator+=(const char *): append(s) directly
- operator+=(const char c): push_back(c)
Both are behavior-preserving and drop the char_traits::copy-from-a-
bounded-buffer path that the analyzer mis-reasons about.
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>1 parent ab96c87 commit 437f52e
2 files changed
Lines changed: 10 additions & 9 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
7 | 7 | | |
8 | 8 | | |
9 | 9 | | |
10 | | - | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
11 | 13 | | |
12 | 14 | | |
13 | 15 | | |
14 | 16 | | |
15 | 17 | | |
16 | | - | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
17 | 21 | | |
18 | 22 | | |
19 | 23 | | |
20 | | - | |
| 24 | + | |
21 | 25 | | |
22 | 26 | | |
23 | | - | |
| 27 | + | |
24 | 28 | | |
25 | 29 | | |
26 | 30 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
422 | 422 | | |
423 | 423 | | |
424 | 424 | | |
425 | | - | |
| 425 | + | |
426 | 426 | | |
427 | 427 | | |
428 | 428 | | |
| |||
442 | 442 | | |
443 | 443 | | |
444 | 444 | | |
445 | | - | |
446 | | - | |
447 | | - | |
448 | | - | |
| 445 | + | |
449 | 446 | | |
450 | 447 | | |
451 | 448 | | |
| |||
0 commit comments