home *** CD-ROM | disk | FTP | other *** search
- Path: sparky!uunet!haven.umd.edu!darwin.sura.net!jvnc.net!rutgers!faatcrl!iecc!compilers-sender
- From: Alfred.Kayser@dnpap.et.tudelft.nl (Alfred Kayser)
- Newsgroups: comp.compilers
- Subject: Re: -O4 in SunOS compiler
- Keywords: sparc, optimize, C, comment
- Message-ID: <92-09-037@comp.compilers>
- Date: 4 Sep 92 08:01:40 GMT
- References: <92-09-017@comp.compilers> <92-09-032@comp.compilers>
- Sender: compilers-sender@iecc.cambridge.ma.us
- Reply-To: Alfred.Kayser@dnpap.et.tudelft.nl (Alfred Kayser)
- Organization: Delft University of Technology, Dept. of Electrical Engineering
- Lines: 39
- Approved: compilers@iecc.cambridge.ma.us
-
- dolf@toet.echo.tds.philips.nl (Dolf Grunbauer) writes:
-
- >David Chase wrote:
- >>> * The compiler may produce 'wrong' code ...
- >An interesting simple program might be the following C code.
- >Depending on the level of optimalisation the answer varies.
- >I tested this on Sun 4.1.1..
- >Options -g, -O and -O2 give a 1 while -O3 and -O4 give 2.
- >(This program has previously been dealt with in comp.lang.c):
-
- Program deleted...
-
- statement of importance: dummy(x.func(&x), x.func(&x));
-
- You've demonstrated why it is bad practice to call functions, with
- side-effects (ie they change the global status from within) in a context
- where the exact calling sequence is undefined... Functions called to
- produce arguments for another function can be called in random order...
-
- Even this statement would produce unprodictable answers:
- dummy(x.val, x.func(&x));
- as it is not defined that x.func is called after or before the value of
- x.val is pushed on the stack...
-
- About the optimization problems, the problem with misusing pointers
- (aliasing things) is that not the optimizer goes wrong, but you did. Al
- these examples of code which produce unprodictable answers, are very fine
- examples of very bad programming practise. Even the best compilers can be
- fooled...
-
- Alfred
- --
- -- Ir. Alfred Kayser. PACS, OS/2, TCP/IP. --- Email: AKayser@et.tudelft.nl --
- -- CARDIT, Delft University of Technology ------------ Tel: (31)-15-786179 --
- -- P.O.Box 5031, 2600 GA Delft, The Netherlands ------ Fax: (31)-15-784898 --
- [Enough already, we all know that it's easy to write C programs with
- --
- Send compilers articles to compilers@iecc.cambridge.ma.us or
- {ima | spdcc | world}!iecc!compilers. Meta-mail to compilers-request.
-