Re: Aliasing in ISO C

cliffc@ami.sps.mot.com (Cliff Click)
19 Feb 1996 16:09:10 -0500

          From comp.compilers

Related articles
Possible to write compiler to Java VM? (I volunteer to summarize) seibel@sirius.com (Peter Seibel) (1996-01-17)
Re: Aliasing in ISO C stevec@pact.srf.ac.uk (1996-02-14)
Re: Aliasing in ISO C rfg@monkeys.com (1996-02-16)
Re: Aliasing in ISO C jplevyak@violet-femmes.cs.uiuc.edu (1996-02-16)
Re: Aliasing in ISO C cdg@nullstone.com (1996-02-16)
Re: Aliasing in ISO C dlmoore@ix.netcom.com (1996-02-17)
Re: Aliasing in ISO C cliffc@ami.sps.mot.com (1996-02-19)
Re: Aliasing in ISO C Joris.Welkenhuysen@ping.be (1996-02-24)
| List of all articles for this month |

From: cliffc@ami.sps.mot.com (Cliff Click)
Newsgroups: comp.compilers
Date: 19 Feb 1996 16:09:10 -0500
Organization: none
References: 96-01-037 96-02-187 96-02-213
Keywords: standards, optimize

dlmoore@ix.netcom.com (David L Moore) writes:


      I had an interesting case where an Ada compiler I was working on
      failed to pass one member of the validation suite with optimization
      on. However, the optimization, which involved optimizing away an
      expression which would have raised an exception, was perfectly valid
      under the old standard. As the new standard requires the exception to
      be raised, it is reasonable to suggest that the bug was not in the
      optimizer, nor in the test suite, but in the standard.


I'd claim the error is in the optimizer. Since the standard now
claims that the exception be raised, the exception becomes a visible
side-effect of the expression and throwing the expression away is
wrong.


A problem with C is that the standard does not claim very much about
when exceptions get raised (generally raising an exception is
"undefined behavior"). Thus the original program may do a load from a
bad address, but if the compiler determines the load is useless it can
remove the load AND the segmentation fault.


Note that the Ada optimizer is still free to toss all of the dead
expression except those parts that test exceptions. In essence, a bad
load in a dead expression becomes a conditional branch to the
exception handler.


Cliff


--
Cliff Click, Ph.D. Compiler Researcher & Designer
RISC Software, Motorola PowerPC Compilers
cliffc@risc.sps.mot.com (512) 891-7240
http://members.aol.com/mjclick1
--


Post a followup to this message

Return to the comp.compilers page.
Search the comp.compilers archives again.