Hartmut Birr wrote:
You are right, but I've still assumed that the pointer is zero or valid. The real problem is, that gcc doesn't stop to validate an expression if the result is determined and if the expression consist of simple expressions which are combined with OR.
i tried the following test application with various configurations of gcc 4.0 and 3.4.2, but it appears to work correctly.
#include <stdio.h>
int main(int argc, char* argv[]) { volatile int *x = NULL;
if(x == NULL || *x == 0) { printf("true\n"); } else { printf("false\n"); } return 0; }