* lib/string.in.h: The first strncpy prototype (with _GL_EXTERN_C)
correctly had _GL_ATTRIBUTE_NONNULL_IF_NONZERO, but the second
prototype (with _GL_FUNCDECL_RPL) used pre-N3322 _GL_ARG_NONNULL.
This triggered a sanitizer failure in test-strncpy when configured
with gl_cv_func_strncpy_works=no.
---
 ChangeLog       | 9 +++++++++
 lib/string.in.h | 3 ++-
 2 files changed, 11 insertions(+), 1 deletion(-)

diff --git a/ChangeLog b/ChangeLog
index c90473a26c..cc895313b5 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,12 @@
+2026-07-31  Lasse Collin  <[email protected]>
+
+       string-h: Fix inconsistent nonnull attributes in strncpy.
+       * lib/string.in.h: The first strncpy prototype (with _GL_EXTERN_C)
+       correctly had _GL_ATTRIBUTE_NONNULL_IF_NONZERO, but the second
+       prototype (with _GL_FUNCDECL_RPL) used pre-N3322 _GL_ARG_NONNULL.
+       This triggered a sanitizer failure in test-strncpy when configured
+       with gl_cv_func_strncpy_works=no.
+
 2026-07-31  Bruno Haible  <[email protected]>
 
        strndup: Fix configure test for "ibm-clang -O2".
diff --git a/lib/string.in.h b/lib/string.in.h
index eb22a912c3..48637be94f 100644
--- a/lib/string.in.h
+++ b/lib/string.in.h
@@ -861,7 +861,8 @@ _GL_WARN_ON_USE (strncat, "strncat is unportable - "
 _GL_FUNCDECL_RPL (strncpy, char *,
                   (char *restrict __dst, char const *restrict __src,
                    size_t __n),
-                  _GL_ARG_NONNULL ((1, 2)));
+                  _GL_ATTRIBUTE_NONNULL_IF_NONZERO (1, 3)
+                  _GL_ATTRIBUTE_NONNULL_IF_NONZERO (2, 3));
 _GL_CXXALIAS_RPL (strncpy, char *,
                   (char *restrict __dst, char const *restrict __src,
                    size_t __n));
-- 
2.55.0


Reply via email to