Skip to content

Commit 437f52e

Browse files
fmichonneauclaude
andcommitted
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

File tree

.github/workflows/rhub.yaml

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,20 +7,24 @@
77
# It is unlikely that you need to modify this file manually.
88

99
name: R-hub
10-
run-name: "${{ github.event.inputs.id }}: ${{ github.event.inputs.name || format('Manually run by {0}', github.triggering_actor) }}"
10+
run-name: >-
11+
${{ github.event.inputs.id || format('Manual run by @{0}', github.triggering_actor) }}:
12+
${{ github.event.inputs.name || github.event.inputs.config }}
1113
1214
on:
1315
workflow_dispatch:
1416
inputs:
1517
config:
16-
description: 'A comma separated list of R-hub platforms to use.'
18+
description: >-
19+
Comma-separated list of R-hub platforms to use.
20+
Full list: https://r-hub.github.io/containers/
1721
type: string
1822
default: 'linux,windows,macos'
1923
name:
20-
description: 'Run name. You can leave this empty now.'
24+
description: 'Run name. You can leave this empty.'
2125
type: string
2226
id:
23-
description: 'Unique ID. You can leave this empty now.'
27+
description: 'Unique ID. You can leave this empty.'
2428
type: string
2529

2630
jobs:

src/ncl/nxsstring.h

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -422,7 +422,7 @@ inline NxsString &NxsString::operator=(
422422
inline NxsString &NxsString::operator+=(
423423
const char *s) /* the C-string to be appended */
424424
{
425-
append(std::string(s));
425+
append(s);
426426
return *this;
427427
}
428428

@@ -442,10 +442,7 @@ inline NxsString &NxsString::operator+=(
442442
inline NxsString &NxsString::operator+=(
443443
const char c) /* the character to append */
444444
{
445-
char s[2];
446-
s[0] = c;
447-
s[1] = '\0';
448-
append(std::string(s));
445+
push_back(c);
449446
return *this;
450447
}
451448

0 commit comments

Comments
 (0)