Reputation: 1
gcc 9.5.0 treates x<x+1 as tautology for "int x".
For the following program, gcc 9.5.0 compiler seems to replaces x<x+1 with 1.
#include <stdio.h>
#define M 0x7FFFFFFF
int main() {
int x = M;
printf("%d\n", x<x+1);
printf("%d\n", x);
printf("%d\n", x+1);
}
So, the output of the program is
1 2147483647 -2147483648
It was not the case with gcc 5.4.0. gcc 5.4.0 prints 0 as the first output.
(For "unsigned x", gcc9.5.0 does not treate x<x+1 as tautology.)
Upvotes: 0
Views: 19