- From: Desrochers, Gary <Gary.Desrochers@fmr.com>
- Date: Wed, 30 Jan 2002 14:33:51 -0500
- To: "'Jean-Christophe Touvet'" <jct@EdelWeb.fr>, "Desrochers, Gary" <Gary.Desrochers@fmr.com>
- Cc: Manuele Kirsch Pinheiro <Manuele.Kirsch_Pinheiro@inrialpes.fr>, Rob Corell <rcorell@adobe.com>, David Binderman <d.binderman@virgin.net>, www-lib@w3.org
By the lexical description of both K&R and ANSI C there is a defined way of performing this operation. Everything is evaluated on the right (the lvalue) before the left (initializer) is operated on. This means that the whole expression needs to be evaluated (this includes assignments to sub expressions) on the right before the lvalue is used. Even though the value is used the expressions on the right will be performed first. The lexical representation is: initializer: = expression = { initializer-list } = { initializer-list , } initializer-list: expression initializer-list , initializer-list { initializer-list } And: expression: * expression & lvalue - expression ! expression ~ expression ++ lvalue -- lvalue lvalue ++ lvalue -- ( type-name ) expression sizeof expression sizeof ( type-name ) ..... Using this lexical analysis: Lets say i = 5. If you do: i++; would make i = 6. ++i; would make i = 6. i = ++i; would make i = 6. i = i++; would make i = 5. -----Original Message----- From: Jean-Christophe Touvet [mailto:jct@EdelWeb.fr] Sent: Wednesday, January 30, 2002 3:06 AM To: Desrochers, Gary Cc: Manuele Kirsch Pinheiro; Rob Corell; David Binderman; www-lib@w3.org Subject: Re: w3c-libwww-5.2.8-7 bug report > Hmmm... Don't want to get into a long drawn out discussion on this but > I don't get why you "concluded" that "i = ++i;" is undefined in K&R "C". > I have the Kernighan an Ritchie book sitting in front of me and it does > describe what would happen with the expression "x = ++i;" and "x = > i++;". And what about "i = i++;" ? Would you increment "i" before or after the assignment ? -JCT-
Received on Wednesday, 30 January 2002 14:34:45 UTC