When I assign i value greater than INT_MAX in this code -
#include <stdio.h>
#include <limits.h>
int main()
{
int i;
i=INT_MAX+3;
printf("%d \n",INT_MAX); //INT_MAX = 2147483647
if(i>INT_MAX)
{
printf("OVERFLOW");
}
else
{
printf("%d",i);
}
return 0;
}
So in this as i=INT_MAX+3; then condition is true and overflow should be printed but it prints some negative value. Is it undefined behaviour ?