slightly OT: c expression evaluation order

Diego 'Flameeyes' Pettenò dgp85 at users.sourceforge.net
Sat Jul 24 13:57:01 CDT 2004


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,
-- 
Diego "Flameeyes" Pettenò
dgp85 at users.sourceforge.net - http://flameeyes.web.ctonet.it/
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 189 bytes
Desc: not available
Url : http://www.winehq.org/pipermail/wine-devel/attachments/20040724/820d6e45/attachment.pgp


More information about the wine-devel mailing list