Lasse Collin wrote: > The tests should pass once C2y is finished and supported by toolchains, > but I suppose it's not useful to add them behind "#if 0" now.
Yes. *Now* is too early. In 10-15 years maybe (because we need to consider also the toolchains of then "old" platforms). > > > With Clang 22.1.8, one test fails: > > > > > > test-bsearch > > > > Oh, interesting: clang appears to have its own database of function > > declarations, instead of relying on the header files. > > The explanation is simpler. In n3322.pdf[1] that is linked from the > test-*.c files, Clang's behavior is described on page 8: > > Clang only respects __attribute__((nonnull)) on function > definitions, but does not respect it on declarations. This is done > specifically so that nonnull annotations in libc headers are > ignored. This does not affect sanitizer behavior or compiler > warnings, which do respect the nonnull attributes. > > glibc's <stdlib.h> includes <bits/stdlib-bsearch.h> which contains an > inline implementation of bsearch. When Clang sees a function > definition, the nonnull attribute affects optimizations and the null > pointer check is removed. Thanks for explaining. > > So, as I see it, only these parts of your patch would be useful: > > > > + * tests/test-wmemchr.c: Add the test null_wmemchr. > > + * tests/test-wmemcmp.c: Add the test null_wmemcmp. > > + * tests/test-wmemcpy.c: Add the test null_wmemcpy. > > + * tests/test-wmemmove.c: Add the test null_wmemmove. > > + * tests/test-wmemset.c: Add the test null_wmemset. > > For some reason glibc's <wchar.h> doesn't have the nonnull attribute in > the prototypes of these functions. Anyway, I attached an updated patch > in case it is useful (feel free to edit etc.). Thanks! This patch could go in. > > But for this part alone, we would also need copyright assignment > > papers from you with the FSF [1][2]. > > I did the test-memcpy.c change first. It's likely too short to be > copyrightable. The rest was repetitive copy-pasting and replacing the > function name. So I think this patch shouldn't cross the threshold for > copyright assignment. The first change is shorter than the "15 lines" (rule of thumb) but is highly original: no other programmer would write it in this way. Therefore it is significant for copyright purposes. So, we can apply this (good) patch only once the paperwork with the FSF is complete. Bruno
