[PATCH v2 3/7] string/test-str*cmp: remove stupid_[strcmp, strncmp, wcscmp, wcsncmp].

Noah Goldstein goldstein.w.n@gmail.com
Mon Jan 10 18:39:56 GMT 2022


On Mon, Jan 10, 2022 at 5:42 AM Wilco Dijkstra <Wilco.Dijkstra@arm.com> wrote:
>
> Hi Noah,
>
> > These implementations are incorrect. There may be a mismatch in s1/s2
> > before invalid memory but no null CHAR / length boundary.
>
> This is not true, see eg. https://en.cppreference.com/w/cpp/string/byte/strcmp.
> Most string functions require that the string is correctly terminated. There
> are only a few exceptions (memchr IIRC), and several generic implementations
> use strlen or strnlen before the main loop.
>
> So if your changes to the testsuite cause these functions to fail, I believe it will
> create failures on other targets too (eg. AArch64 strcmp does a check for zero
> and continues reading if there is no zero).
>
> It's OK to remove these weirdly named functions (I already removed them from
> the benchtests directory), however we should ensure the strings are valid to
> avoid reporting errors on existing implementations.

Good catch! Had always thought the per-byte loop that stopped on mismatch
was the functionality we had to emulate.

I'll update the commit message in V3 and make sure all the added tests
don't test this edge case.
>
> Cheers,
> Wilco


More information about the Libc-alpha mailing list