Michael Jung wrote:
I've always thought that the order in which subexpressions are evaluated is not specified in the C language. Isn't there the danger of a NULL pointer dereference given here?
I don't think so. Order is expressed and is from left to right, so if you have two functions and do
func1() && func2()
if func1() will be evalutated as false, func2() will never be called. I saw code wrote without if statements and using directly the logic operators (also if I don't like this syntax) and also Gentoo's scripts (ebuilds and init.d) uses this syntax for some conditional statements.
So it should be sure that there won't be a null pointer deference.
Regards,