I want to know if there is a way for the compiler to understand that two statements ifcannot be true at the same time and add an “implicit other”. For example, in this code example:
int main() {
char c;
scanf_s("%c", &c, 1);
if (c == '1') {
printf("received 1\n");
}
if (c == '2') {
printf("received 2\n");
}
return 0;
}
cIt can not be '1'and '2', but after compiling in Visual Studio and disassembly, I noticed that he would check the second if, no matter what.
yeger source
share