#include <stdio.h>
#include <windows.h>
int main(int argc, char** argv)
{
char *x = malloc(500);
char *y = malloc(500);
strcpy(x, "abc");
strcpy(y, "abc");
printf("strcmp(%s,%s) = %d\n", x, y, strcmp(x,y));
memset(x, 0, 500);
strcpy(x, "xyz");
printf("strcmp(%s,%s) = %d\n", x, y, strcmp(x,y));
}
when running the above code with the optimizer OFF (through project options) I get the following output
strcmp(abc, abc) = 0
strcmp(xyz, abc) = (not zero)
when I turn it on (maximise speed) I get
strcmp(abc, abc) = 0
strcmp(xyz, abc) = 0
Can anyone explain this? I put it as a bug because generally I'd expect code to behave the same with optimisation on and off.
I'm using Version 7.00.355 Win64