[PATCH] mbrtowc: Avoid compare with the result pointer add

Sam James sam@gentoo.org
Fri Jan 10 03:15:05 GMT 2025


YunQiang Su <yunqiang@isrc.iscas.ac.cn> writes:

>   inbuf = (const unsigned char *) s;
>   endbuf = inbuf + n;
>   if (__glibc_unlikely (endbuf < inbuf))  // <--- here
>     {
>       endbuf = (const unsigned char *) ~(uintptr_t) 0;
>       if (endbuf == inbuf)
>         goto ilseq;
>     }
>
> Some compilers (such as clang 20), may treat that the endbuf
> greater than inbuf always, as n is a `size_t`, aka `unsigned long`.

Please always mention what problem you're seeing in the wild, too. A
warning? Error? Test failure?

(I see you've retracted the patch, but the comment stands for future changes).


More information about the Libc-alpha mailing list