If x is unused, the compiler is allowed to remove the assignment. If it does that optimization after it removes the "redundant" null pointer test, the optimizer has legally altered your program to remove the null pointer check you thought you had.
http://blog.llvm.org/2011/05/what-every-c-programmer-should-...
Please read that article, and the rest in the series. Undefined behavior is far more pervasive than you think.