home *** CD-ROM | disk | FTP | other *** search
- Path: sparky!uunet!haven.umd.edu!darwin.sura.net!wupost!uwm.edu!ogicse!unmvax!uservx.plk.af.mil!simonich
- From: simonich@uservx.plk.af.mil
- Newsgroups: comp.os.linux
- Subject: Re: GCC 2.2.2d bug
- Message-ID: <1992Sep4.210545.36040@uservx.plk.af.mil>
- Date: 4 Sep 92 21:05:45 GMT
- Article-I.D.: uservx.1992Sep4.210545.36040
- References: <1992Sep4.202913.14346@hippo.ru.ac.za> <1992Sep4.230902.2523@novell.com>
- Organization: Phillips Laboratory - Kirtland AFB
- Lines: 36
-
- 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.
-