My favorites | Sign in
Project Home Downloads Wiki Issues Source
READ-ONLY: This project has been archived. For more information see this post.
Search
for
  Advanced search   Search tips   Subscriptions
Issue 9: fastmemcmp_inlined is incorrect
1 person starred this issue and may be notified of changes. Back to list
Status:  Fixed
Owner:  ----
Closed:  Jan 2013


 
Reported by tlip...@gmail.com, Dec 28, 2012
What steps will reproduce the problem?

char a[] = {0, 0, 0, 0x80};
char b[] = {0, 0, 0, 0x01};

assert(fastmemcmp_inlined(a, b, 4) == memcmp(a, b, 4));

What is the expected output? What do you see instead?

memcmp is supposed to be bytewise lexicographic comparison, but there is a bug in the inlined implementation:

  while (a < a_limit) {
    int d = static_cast<uint32>(*a++) - static_cast<uint32>(*b++);
    if (d) return d;
  }

incorrectly upcasts from 'const char *' to uint32, which has sign-extension behavior.

The arguments here should probably be made into const void * to match the signature of memcmp.

What version of the product are you using? On what operating system?
68c456e59482a26c595a9f4c5cc3d661e56a21b0
Jan 18, 2013
Project Member #1 p...@google.com
Should be fixed in version 0.9.3. (Supersonic will build with -funsigned-char flag)
In version 0.9.4 we will fix the implementation of this function as well.
Status: Fixed

Powered by Google Project Hosting