[Bug sanitizer/55309] gcc's address-sanitizer 66% slower than clang's

kcc at gcc dot gnu.org gcc-bugzilla@gcc.gnu.org
Fri Feb 22 14:54:00 GMT 2013


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=55309

--- Comment #50 from Kostya Serebryany <kcc at gcc dot gnu.org> 2013-02-22 14:54:24 UTC ---
reproducer: 

#include <string.h>
#include <stdio.h>
int foo(const char *x, const char *y, int len) {
  return memcmp(x, y, len);
}
int main() {
  printf("%d\n", foo("perlio", "unix", 6));
}

clang does not report a warning here, but gcc does. 
This is a gray area for me, not sure if we should treat this as a buggy code. 

on one hand, memcmp gets size=6, while one of the buffers is smaller. 
otoh, the first bytes of the strings are different and memcmp should not read
the rest. 

I vaguely remember some similar case where we decided that the code is correct. 
Anyone?



More information about the Gcc-bugs mailing list