This is the mail archive of the libc-alpha@sourceware.org mailing list for the glibc project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: PATCH: New 64 bit wcscmp implementation


On Fri, 16 Sep 2011, Dmitrieva Liubov wrote:

> Hello,
> 
> The example mentioned by Joseph doesn't show that for old wcscmp
> version the comparisons are always done in an unsigned type even when
> wchar_t is signed.

Well - it compares in an unsigned type then subtracts in an unsigned type 
and returns the result in a signed type (the sign after conversion to 
signed possibly being wrong).  The precise form of the bug isn't 
particularly significant.

In properly fixed testcases, UCHAR (the type for the comparison) should be 
wchar_t not uint32_t in the wide-character case, and the return value in 
STUPID_STRCMP etc. can't be determined directly by a subtraction that 
might overflow, it needs to be of the form (a < b ? -1 : a == b ? 0 : 1) 
or similar.

-- 
Joseph S. Myers
joseph@codesourcery.com


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]