On Fri, 8 Jun 2001, Andrew James Richardson wrote: >> > < if ( !image ) >> > --- >> > > if ( !image || !image->Data) >> > > >Brian, > > I thought that in the C specs you can't be guarenteed the order of >evaluation in an if brace. Surely a safer bet is > > if(!image){ > if(!image->Data){ > ... > } > } > > If you know better I stand corrected, I'm just thinking that not all >target platforms will use gcc (which I presume is the one that is used in >this case). The associativity is left to right. It is guaranteed standard C. if(a && b && c && d) Where a is evaluated first always, then b, but only if a is true. The first left to right statement that is false stops further conditions from being checked. This allows for example - optimization, by putting the conditionals in order of most likely to be false to least likely, you optimize for the most common case in the test. When using ||, the associativity is the same, but then in the case: if(a || b || c || d) b is only evaluated if a is false. The first one evaluating "true" from left to right makes the whole statement true, and thus no further condition testing need be made. Also, your above example does not do the same as the original. The original says "if a and b then c", while yours says: "if a and b then c" Your multiple if block is syntactically equivalent to if ( !image && !image->Data) Notice the flipping of || to && from the original example. ---------------------------------------------------------------------- Mike A. Harris Shipping/mailing address: OS Systems Engineer 190 Pittsburgh Ave., Sault Ste. Marie, Red Hat Inc. Ontario, Canada, P6C 5B3 http://www.redhat.com Phone: (705)949-2136 ---------------------------------------------------------------------- Latest XFree86 test RPMS: ftp://people.redhat.com/mharris/testing _______________________________________________ Dri-devel mailing list [EMAIL PROTECTED] http://lists.sourceforge.net/lists/listinfo/dri-devel