I recently noticed that it's possible to verify the existence of a variable (e.g pointer type in C) and just after, verify an element inside of that variable (e.g dereferencing the pointer) in a same control flow (e.g if statement).
Before noticing
if (my_array)
{
if (my_array[n])
{
//Do something
}
}
After noticing
if (my_array
&& my_array[n])
{
//Do something
}
I was a little bit suprised about that behaviour, and I used valgrind to see if the system has been "kind" with me during the execution of the program, but valgrind was straight and said that I've got
ERROR SUMMARY: 0 errors from 0 contexts.
So I whish to know if the compiler only refers to operators, in order to create a sort of flowchart, or it's another type of evaluation. And does every compilers use the same type of behavior ?