From: Mike McCarty (jmccarty_at_ssd.usa.alcatel.com)
Date: 2001-01-03 16:01:28
On Wed, 3 Jan 2001, Spiro Trikaliotis wrote: > Hello to all who answered, > > > On Tue, Jan 02, 2001 at 07:15:32PM +0100, Spiro Trikaliotis wrote: > > > Forgive me, but if my memory serves me right, C (at least pre-ANSI) does > NOT > > > define the order in which this will be evaluated, so the second part > (c!=62) > > > might be evaluated BEFORE the first part with the assignment, in that > case, > > > this will NOT evaluate to the expected condition. > > > That is incorrect. C evaluates boolean expressions as shortcuts with each > > boolean operator being a sequence point. If the left operand is enough to > > determine the value of the expression result, all others will not get > > evaluated. Because of this, one can write things like > > Oh yeah, I must admit after reading the C language reference, that my > statement is NOT true. Possibly, it's my fault, because I learned C with > K&R, 1st edition, which is pre-ANSI. In that case, my statement was correct, > anyway, after reading the (ANSI-)C reference ("sequency points"), I must > admit that I'm not correct. > > Thank you for answering, as I now know more than before, and can write > programs with much less if()-statements than before... ;-) This behavior predates ANSI C. The so-called K&R C also had this guaranteed behavior. Even SmallC by Hendrix had this. Mike ---- char *p="char *p=%c%s%c;main(){printf(p,34,p,34);}";main(){printf(p,34,p,34);} This message made from 100% recycled bits. I can explain it for you, but I can't understand it for you. I don't speak for Alcatel <- They make me say that. ---------------------------------------------------------------------- To unsubscribe from the list send mail to majordomo_at_musoftware.de with the string "unsubscribe cc65" in the body(!) of the mail.
This archive was generated by hypermail 2.1.3 : 2001-12-14 22:05:38 CET