From: simonich@uservx.plk.af.mil Subject: Re: GCC 2.2.2d bug Date: 4 Sep 1992 21:05:45 GMT
In article <1992Sep4.230902.2523@novell.com>, bboerner@novell.com (Brendan B. Boerner) writes:
> In article <1992Sep4.202913.14346@hippo.ru.ac.za> pi@cs.sun.ac.za writes:
>>I have found that gcc is generating the wrong code for the following
>>code fragment:
>>
>> int p = 10;
>> p = p++;
>>
>>From my C background, I have found the value to be 10. Unfortunately
>>(for the gcc maintainers) the result is 11.
>
> I have this idea that if you posted this to comp.lang.c, Chris Torek or
> someone similar would point out that this is correct behaviour. My gut
> feeling is that it SHOULD be 11 but I'm not a C guru.
>
> Later,
> Brendan
> --
> Brendan B. Boerner Phone: 512/346-8380
> Internet: bboerner@novell.com MHS: bboerner@novell
> Please use ^^^^^^^^^^^^^^^^^ if replying by mail.
I will admit that it isn't the ASCII C standard but on page 46 of
The C Programming Language (second edition) by Kernighan and Ritchie
they give the specific example:
"If n is 5, then
x = n++;
sets x to 5, but
x = ++n;
sets x to 6."
I agree with a previous poster that this code fragment is IMHO, very
poor code.