home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1992 #19 / NN_1992_19.iso / spool / comp / compiler / 1498 < prev    next >
Encoding:
Internet Message Format  |  1992-09-01  |  1.7 KB

  1. Path: sparky!uunet!zaphod.mps.ohio-state.edu!sol.ctr.columbia.edu!usc!rutgers!faatcrl!iecc!compilers-sender
  2. From: chased@rbbb.Eng.Sun.COM (David Chase)
  3. Newsgroups: comp.compilers
  4. Subject: Re: -O4 in SunOS compiler
  5. Keywords: sparc, optimize, C
  6. Message-ID: <92-09-017@comp.compilers>
  7. Date: 1 Sep 92 23:10:58 GMT
  8. References: <92-08-164@comp.compilers> <92-09-003@comp.compilers>
  9. Sender: compilers-sender@iecc.cambridge.ma.us
  10. Reply-To: chased@rbbb.Eng.Sun.COM (David Chase)
  11. Organization: Sun Microsystems, Mt. View, Ca.
  12. Lines: 25
  13. Approved: compilers@iecc.cambridge.ma.us
  14.  
  15. wismuell@Informatik.TU-Muenchen.DE (Roland Wismueller) writes:
  16. >So -O4 has several consequences:
  17.    ...
  18. >  * The compiler may produce 'wrong' code
  19.  
  20. >The last item is common to all optimizing compilers (at least for C),
  21. >since aliasing analysis relies on some assumptions that must hold for a
  22. >program, e.g.  the sequence 'p = &i; *(p+offset) = 123;' will access (a
  23. >component of) i, but no other variable. Of course, you cannot enforce this
  24. >in C.
  25.  
  26. What you have there is a case of "undefined behavior" (as specified by the
  27. ANSI and ISO C language standards).  When this is the case, it is not
  28. "wrong" to produce code that has different results depending upon the
  29. optimization level.  Detecting such code is difficult, but not impossible.
  30. (Example implementation -- generate a map for all of memory, and check
  31. each instance of pointer arithmetic and dereferencing to ensure that it
  32. conforms to the C standard.  You may find this too costly, but it is not
  33. at all impossible.)
  34.  
  35. David Chase
  36. Sun
  37. -- 
  38. Send compilers articles to compilers@iecc.cambridge.ma.us or
  39. {ima | spdcc | world}!iecc!compilers.  Meta-mail to compilers-request.
  40.