bug-gnu-emacs
[Top][All Lists]
Advanced

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

bug#29799: 24.5; cl-loop guard clause missing


From: Tino Calancha
Subject: bug#29799: 24.5; cl-loop guard clause missing
Date: Thu, 21 Dec 2017 18:38:20 +0900

X-Debbugs-CC: monnier@iro.umontreal.ca,npostavs@gmail.com

Consider the following snippet code:

--8<-----------------------------cut here---------------start------------->8---
(require 'cl-lib)
(let* ((size 7)
       (arr (make-vector size 0)))
  (cl-loop for k below size
           for x = (* 2 k) and y = (1+ (elt arr k))
           collect (list k x y)))
--8<-----------------------------cut here---------------end--------------->8---

When you execute the form above it fails because
the loop overrun `arr'.

The equivalent code in CL works:
--8<-----------------------------cut here---------------start------------->8---
(let* ((size 7)
       (arr (make-array size :initial-element 0)))
  (loop :for k :below size
           :for x = (* 2 k) :and y = (1+ (elt arr k))
           :collect (list k x y)))
--8<-----------------------------cut here---------------end--------------->8---

* The expansion of `loop' in CL checks the condition
  (>= k 7)
  right before update the internal variables (`x' and `y').

* The expansion of `cl-loop' instead, doesn't check the condition
  before update the vars  =>  in the code above we overrun `arr'.


In GNU Emacs 24.5.1 (x86_64-pc-linux-gnu, GTK+ Version 3.22.11)
 of 2017-09-12 on hullmann, modified by Debian
Windowing system distributor `The X.Org Foundation', version 11.0.11902000
System Description:     Debian GNU/Linux 9.3 (stretch)





reply via email to

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