* bug#9769: Misplaced tail call optimization @ 2011-10-16 20:29 Ludovic Courtès 2011-10-17 8:33 ` Andy Wingo 2011-10-20 21:51 ` Andy Wingo 0 siblings, 2 replies; 3+ messages in thread From: Ludovic Courtès @ 2011-10-16 20:29 UTC (permalink / raw) To: 9769 (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'. ^ permalink raw reply [flat|nested] 3+ messages in thread
* bug#9769: Misplaced tail call optimization 2011-10-16 20:29 bug#9769: Misplaced tail call optimization Ludovic Courtès @ 2011-10-17 8:33 ` Andy Wingo 2011-10-20 21:51 ` Andy Wingo 1 sibling, 0 replies; 3+ messages in thread From: Andy Wingo @ 2011-10-17 8:33 UTC (permalink / raw) To: Ludovic Courtès; +Cc: 9769 The title of this bug isn't quite right. It's not that Guile is intentionally treating the call to fail as a tail call; it's some bug in the way that "labels allocated" procedures in compile-glil.scm are called. Andy -- http://wingolog.org/ ^ permalink raw reply [flat|nested] 3+ messages in thread
* bug#9769: Misplaced tail call optimization 2011-10-16 20:29 bug#9769: Misplaced tail call optimization Ludovic Courtès 2011-10-17 8:33 ` Andy Wingo @ 2011-10-20 21:51 ` Andy Wingo 1 sibling, 0 replies; 3+ messages in thread From: Andy Wingo @ 2011-10-20 21:51 UTC (permalink / raw) To: Ludovic Courtès; +Cc: 9769-done Fixed in git. Thanks for the report! commit aa9c19858872a135ea959066fff26f86527a1bd0 Author: Andy Wingo <wingo@pobox.com> 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/ ^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2011-10-20 21:51 UTC | newest] Thread overview: 3+ messages (download: mbox.gz follow: Atom feed -- links below jump to the message on this page -- 2011-10-16 20:29 bug#9769: Misplaced tail call optimization Ludovic Courtès 2011-10-17 8:33 ` Andy Wingo 2011-10-20 21:51 ` Andy Wingo
This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox; as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).