[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Tinycc-devel] Proposal for handling alloca(). Anyone see a problem

From: Philippe Ribet
Subject: Re: [Tinycc-devel] Proposal for handling alloca(). Anyone see a problem with it?
Date: Tue, 08 May 2007 19:08:10 +0200
User-agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.6) Gecko/20040413 Debian/1.6-5

David A. Wheeler wrote:
There lots of interesting alloca() comments, thanks so much! Here are some replies...

Fred Weigel:
But, you may be using alloca() in a parameter sub-_expression_! (at which
point later earlier parameters can no longer be correctly retrieved).
Which is the problem you are thinking about...

Right, that's exactly the problem I was concerned about.  But Daniel Glöckner has just enlightened me; it appears that tcc doesn't HAVE anything else on the stack when it evaluates a parameter sub-_expression_.  Stuff always gets moved to temp variables instead; I didn't fully appreciate that before.  So this problem, which WOULD occur in many other implementation approaches, is a non-problem in the tcc case because of how tcc works.

I'm sorry to ask this question so late, but I still didn't understood how alloca *could* work on the stack with single pass compiler. Notice I didn't look at the proposed patch because I'm not concerned by the way the code do its work. I'm asking from a pure theorical point of view. Imagine some code like this:

f() {
    local variable 1; //on the stack
    { // new block 1
       local variable 2; // on the stack
       { // new block 2
          var1 = alloca(4); // this will be pushed on the stack after variable 2, because it's a single pass compiler
    } // this closes block 1 thus freeing local variable 2, but alloca memory should be kept (until the function returns). How to do that?
    use var1;

Best regards,

Philippe Ribet

                         The README file said
              "Requires Windows 95, NT 4.0, or better."
                    So... I installed it on Linux!

reply via email to

[Prev in Thread] Current Thread [Next in Thread]