public inbox for glibc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug libc/16885] New: strcmp() on sparc64 can return wrong result
@ 2014-04-29 19:48 baggett.patrick at gmail dot com
  2014-04-29 19:48 ` [Bug libc/16885] " baggett.patrick at gmail dot com
                   ` (10 more replies)
  0 siblings, 11 replies; 12+ messages in thread
From: baggett.patrick at gmail dot com @ 2014-04-29 19:48 UTC (permalink / raw)
  To: glibc-bugs

https://sourceware.org/bugzilla/show_bug.cgi?id=16885

            Bug ID: 16885
           Summary: strcmp() on sparc64 can return wrong result
           Product: glibc
           Version: 2.18
            Status: NEW
          Severity: normal
          Priority: P2
         Component: libc
          Assignee: unassigned at sourceware dot org
          Reporter: baggett.patrick at gmail dot com
                CC: drepper.fsp at gmail dot com

In 2011, strcmp() was rewritten for sparc64 to be faster in
ad69cc2652c0422ebac3296d914c25e470498ce1 by David S. Miller. However, there is
a particularly strange case where it can return the wrong value: if the bytes
after the last bytes being compared are both zero.

e.g.

char a[2] = { 0, 0 };
char b[2] = { 1, 0 };

printf("%d", strcmp(a,b));

This should print "-1" because the first byte differs by 1. The second byte
should not be examined. However, it erroneously prints "0". Changing either
a[1] or b[1] to a non-zero value causes the "-1" to be correctly returned. For
example, this returns the correct value of -1:

char a[2] = { 0, 0xaa };
char b[2] = { 1, 0 };

printf("%d", strcmp(a,b));

-- 
You are receiving this mail because:
You are on the CC list for the bug.


^ permalink raw reply	[flat|nested] 12+ messages in thread

end of thread, other threads:[~2015-01-30  8:47 UTC | newest]

Thread overview: 12+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2014-04-29 19:48 [Bug libc/16885] New: strcmp() on sparc64 can return wrong result baggett.patrick at gmail dot com
2014-04-29 19:48 ` [Bug libc/16885] " baggett.patrick at gmail dot com
2014-04-30 20:03 ` davem at davemloft dot net
2014-05-01 19:15 ` cvs-commit at gcc dot gnu.org
2014-05-01 20:19 ` cvs-commit at gcc dot gnu.org
2014-05-01 20:21 ` cvs-commit at gcc dot gnu.org
2014-05-01 20:23 ` cvs-commit at gcc dot gnu.org
2014-05-01 20:24 ` cvs-commit at gcc dot gnu.org
2014-05-01 20:25 ` cvs-commit at gcc dot gnu.org
2014-05-01 21:01 ` davem at davemloft dot net
2014-06-12 19:30 ` fweimer at redhat dot com
2015-01-30  8:47 ` fweimer at redhat dot com

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).