Re: Figure 1.9 from the Dragon Book

Christopher Brian Colohan <colohan+@cs.cmu.edu>
24 Aug 2001 01:04:01 -0400

          From comp.compilers

Related articles
Figure 1.9 from the Dragon Book kvinay@ip.eth.net (Vinay Kakade) (2001-08-20)
Re: Figure 1.9 from the Dragon Book kurt@inobiz.se (2001-08-24)
Re: Figure 1.9 from the Dragon Book colohan+@cs.cmu.edu (Christopher Brian Colohan) (2001-08-24)
| List of all articles for this month |

From: Christopher Brian Colohan <colohan+@cs.cmu.edu>
Newsgroups: comp.compilers
Date: 24 Aug 2001 01:04:01 -0400
Organization: Carnegie Mellon Univ. -- Computer Science Dept.
References: 01-08-118
Keywords: books
Posted-Date: 24 Aug 2001 01:04:01 EDT

Vinay Kakade <kvinay@ip.eth.net> writes:
> I could not understand why the "error handler" needs to be connected
> to "Intermediate Code Generator", "Code Optimizer" and "Code
> Generator". In other words, for the compiler model in figure 1.9, is
> it possible that some erroneous program reaches "Intermediate Code
> Generator" phase?


Sure, I can give you an example. With gcc some warnings are only
emitted when you enable the optimizer. For example:


int main(int argc, char *argv[]) {
        int i;


        if(argc > 3) i = 1;


        return i;
}


If you compile this program with "gcc -Wall", no warnings result. If
you compile it with "gcc -Wall -O3" you get the warning:


foo.c: In function `main':
foo.c:2: warning: `i' might be used uninitialized in this function


This is because the compiler needs to do live variable analysis to
detect this erronous condition, and it only does this analysis while
optimizing.


Chris
--
Chris Colohan Email: chris@colohan.ca PGP: finger colohan@cs.cmu.edu
Web: www.cs.cmu.edu/~colohan Phone: (412)268-4751


Post a followup to this message

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