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?