Subject: bug#9769: closed (Re: bug#9769: Misplaced tail call optimization)

From: [email-masked] (GNU bug Tracking System)
Date: Thu, 20 Oct 2011 21:53:02 +0000

Your bug report

#9769: Misplaced tail call optimization

which was filed against the guile package, has been closed.

The explanation is attached below, along with your original report.
If you require more details, please reply to [email-masked].

-- 
9769: http://debbugs.gnu.org/cgi/bugreport.cgi?bug=9769
GNU Bug Tracking System
Contact [email-masked] with problems

Subject: Re: bug#9769: Misplaced tail call optimization
From: Andy Wingo <[email-masked]>
To: [email-masked] (Ludovic Courtès)
Cc: [email-masked]
Date: Thu, 20 Oct 2011 23:51:20 +0200
List-Id: <debbugs-submit.debbugs.gnu.org>

Fixed in git.  Thanks for the report!

commit aa9c19858872a135ea959066fff26f86527a1bd0
Author: Andy Wingo <[email-masked]>
Date:   Thu Oct 20 23:50:05 2011 +0200

    fix misallocation of some <fix> procedures
    
    * module/language/tree-il/analyze.scm (analyze-lexicals): When stepping
      into a non-tail form, we know that labels allocation will be invalid,
      so use an empty labels set.  Fixes http://debbugs.gnu.org/9769.
    
    * test-suite/tests/tree-il.test ("labels allocation"): Add a test.

-- 
http://wingolog.org/

Subject: Misplaced tail call optimization
From: [email-masked] (Ludovic Courtès)
To: [email-masked]
Date: Sun, 16 Oct 2011 22:29:00 +0200
List-Id: <debbugs-submit.debbugs.gnu.org>

(This is a copy of <http://savannah.gnu.org/bugs/?34300>, so it doesn't
get lost.  :-))

Consider this example:

  (define bar
    (lambda ()
      (let ((fail (lambda () 'fail)))
        (let loop ((a (iota 3)))
          (if (pair? a)
              (loop (cdr a))
              (fail)))
        (pk 'done))))

This function should return 'done but it instead returns 'fail, because both
the call to `loop' and the call to `fail' are compiled as if they were tail
calls.

To reproduce the test, turn partial evaluation off---otherwise the call to
`fail' is inlined and the problem doesn't show up.

Ludo'.