W3C home > Mailing lists > Public > www-lib@w3.org > January to March 2002

RE: w3c-libwww-5.2.8-7 bug report

From: Desrochers, Gary <Gary.Desrochers@fmr.com>
Date: Wed, 30 Jan 2002 15:03:29 -0500
Message-ID: <1E053503E50CD5118EB500A0C9DB229EE1B740@MSGMMK578NTS.fmr.com>
To: "'Joe Konczal'" <joe.konczal@nist.gov>, Jean-Christophe Touvet <jct@EdelWeb.fr>
Cc: "Desrochers, Gary" <Gary.Desrochers@fmr.com>, Manuele Kirsch Pinheiro <Manuele.Kirsch_Pinheiro@inrialpes.fr>, Rob Corell <rcorell@adobe.com>, David Binderman <d.binderman@virgin.net>, www-lib@w3.org
Hmmm...  Curious...  Try this:

#include <stdio.h>
#include <stdlib.h>

int
main(int argc, char *argv[])
{
  int i;
  int m;
  int n;

  i = 0;
  i = i++;
  printf("i = 0, i = i++, i => %d\n", i);

  i = 0;
  i = ++i;
  printf("i = 0, i = ++i, i => %d\n", i);

  i = 0;
  n = ++i;

  printf("i = 0, n = ++i, n => %d\n", n);

  i = 0;
  m = i++;
  printf("i = 0, m = i++, m => %d\n", m);

  exit(0);
}

-----Original Message-----
From: Joe Konczal [mailto:joe.konczal@nist.gov]
Sent: Wednesday, January 30, 2002 12:08 PM
To: Jean-Christophe Touvet
Cc: Desrochers, Gary; Manuele Kirsch Pinheiro; Rob Corell; David
Binderman; www-lib@w3.org
Subject: Re: w3c-libwww-5.2.8-7 bug report


Jean-Christophe Touvet wrote:

>>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-
>
>
After, of course.  But the result would be the same as incrementing it 
before.  There is only one "i" and it gets incremented either way.  Try 
this little program, and let me know if you find any implementation of C 
where the value of "i" is not one in both cases.

#include <stdio.h>
#include <stdlib.h>

int
main(int argc, char *argv[])
{
  int i;

  i = 0;
  i = i++;
  printf("i = 0, i = i++, i => %d\n", i);

  i = 0;
  i = ++i;
  printf("i = 0, i = ++i, i => %d\n", i);

  exit(0);
}
Received on Wednesday, 30 January 2002 15:04:21 GMT

This archive was generated by hypermail 2.2.0+W3C-0.50 : Monday, 23 April 2007 18:18:40 GMT