On 2026-07-31 08:26, Lasse Collin wrote:
I have a hunch that only GCC < 15 and glibc's headers are problematic,
so excluding those might keep "make check" happy everywhere. If it
doesn't, then it reveals what other platforms have problems with N3322.
The more I think about this, the more I think our current approach is too risky
and has too little benefit for the risk. We are barking up the wrong tree.
Instead, aside from documenting the N3322 issue, we should do either of the
following:
* In gnulib-readme.texi say that portable code should not assume N3322, other
than assuming that NULL + 0 works.
* Implement a new Gnulib module null-length-0, which supports the rest of
N3322, the part that says standard functions support the idea of null pointers
with length 0.
If we do the former, we should disable our test cases for null pointers of length
0, unless perhaps 202311 < __STDC_VERSION__. If we do the latter, those test
cases should be enabled only if the null-length-0 module is in use.
If we do the latter, null-length-0 should be conservative: it should assume
that the current platform does not support N3322 unless we know for sure
otherwise (and right now, we don't really know otherwise, for any platform). No
Gnulib modules should depend on null-length-0 for now, as this stuff is still
too unreliable. The null-length-0 module can operate by replacing the affected
functions. That is, instead of this in lib/string.in.h:
-#if defined __GNUC__ && __GNUC__ >= 15 && !defined __clang__
-# ifndef memcpy
-_GL_EXTERN_C void *memcpy (void *__dest, const void *__src, size_t __n)
-# if __GLIBC__ + (__GLIBC_MINOR__ >= 2) > 2
- _GL_ATTRIBUTE_NOTHROW
-# endif
- _GL_ATTRIBUTE_NONNULL_IF_NONZERO (1, 3)
- _GL_ATTRIBUTE_NONNULL_IF_NONZERO (2, 3);
-# endif
-#endif
... we should have something like this:
+#if @GNULIB_NULL_LENGTH_0@
+_GL_STRING_INLINE void *
+rpl_memcpy (void *__dest, void const *__src, size_t __n)
+{
+ return __n ? memcpy (__dest, __src, __n) : __dest;
+}
+#endif
... with the usual business later that #defines memcpy to rpl_memcpy or does a
template for C++.