google / supersonic

Supersonic is an ultra-fast, column oriented query engine library written in C++

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

fastmemcmp_inlined is incorrect

GoogleCodeExporter opened this issue · comments

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

Original issue reported on code.google.com by tlip...@gmail.com on 29 Dec 2012 at 12:14

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.

Original comment by p...@google.com on 18 Jan 2013 at 6:08

  • Changed state: Fixed