home *** CD-ROM | disk | FTP | other *** search
- Newsgroups: gnu.gcc.bug
- Path: sparky!uunet!cis.ohio-state.edu!tis.llnl.gov!carlson
- From: carlson@tis.llnl.gov (John Carlson)
- Subject: Increment isn't done before assigment in unoptimized version
- Message-ID: <135156@lll-winken.LLNL.GOV>
- Sender: gnulists@ai.mit.edu
- Organization: Lawrence Livermore National Laboratory
- Distribution: gnu
- Date: Wed, 2 Sep 1992 09:01:55 GMT
- Approved: bug-gcc@prep.ai.mit.edu
- Lines: 32
-
- Machine: Sparcstation 2
- OS: Sun OS 4.1.1
- Compiler: gcc-2.2.2
-
-
- The follow program gives difference result when compiled with
- and without the -O option to gcc.
-
- #include <stdio.h>
- main ()
- {
- int i = 0;
- i = i++;
- printf("should be 1->%d\n", i);
- }
-
-
- The unoptimized version prints:
-
- should be 1->0
-
- The optimized version prints:
-
- should be 1->1
-
- Guess the moral of the story is to use the optimized version.
- Either that or I was too tired when programming.
- (Yeay! The program works now!)
-
- John Carlson
- carlson@yottzumm.tis.llnl.gov
-
-