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

Sam James sam@gentoo.org
Fri Jan 10 06:15:52 GMT 2025


Sam James <sam@gentoo.org> writes:

> 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).

I assume the context is https://github.com/llvm/llvm-project/issues/122400.


More information about the Libc-alpha mailing list