Open
Description
#include <stdio.h>
#include <string.h>
int foo(const char *a, const char *b)
{
return memcmp(a,b,5);
}
int main()
{
int x=foo("HELLO C23","C23 STD");
int y=memcmp("HELLO C23","C23 STD",5);
printf("%d = %d\n",x, y);
}
At -O0 optimization level, when called through function foo(), it incorrectly returns 5 instead of 1.
5 = 1
Reproduce link:
https://godbolt.org/z/4aqY8x3TT