Skip to content
Prev 11100 / 12125 Next

[R-pkg-devel] truncating strings on purpose

? Wed, 11 Dec 2024 12:12:11 +0000
Brad Eck <bradleyjeck at gmail.com> ?????:
GCC documentation suggests setting the length argument to _one less_
than sizeof destination buffer in addition to terminating the string:
https://gcc.gnu.org/onlinedocs/gcc-14.2.0/gcc/Warning-Options.html#index-Wstringop-truncation

        strncpy(trunc_s1, s1, sizeof trunc_s1 - 1);
        trunc_s1[sizeof trunc_s1 - 1] = '\0';