home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1992 #20 / NN_1992_20.iso / spool / comp / compiler / 1518 next >
Encoding:
Internet Message Format  |  1992-09-07  |  2.3 KB

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