RE: w3c-libwww-5.2.8-7 bug report

Off topic but fun.:-)

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



> > And what about "i = i++;" ?
> >
> > Would you increment "i" before or after the assignment ?
>
> 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.

test>uname -a
SunOS test 5.5.1 Generic_103640-31 sun4m sparc SUNW,SPARCstation-5
test>gcc -v
gcc version 2.7.2
test>cat x.c

#include <stdio.h>

int main()
{
        int x = 0;
 
        x = x++;
        printf("%d\n", x);
        return(0);
}

test>gcc -Wall x.c ; ./a.out
0
test>gcc -Wall -O x.c ; ./a.out
1
test>

 With gcc 2.95.2 on Solaris 8, with or without optimization, the result
is always 1. But if I replace "x = x++;" with "x = x++ + 1;", the result
is 1 without optimization and 2 with -O (and still no compiler warning
of course).

    -JCT-

PS: we're now totally off-topic, but we can follow this discussion
privately if you want.

Received on Wednesday, 30 January 2002 15:09:41 UTC