From debbugs-submit-bounces@debbugs.gnu.org Wed Sep 15 15:12:29 2021 Received: (at submit) by debbugs.gnu.org; 15 Sep 2021 19:12:29 +0000 Received: from localhost ([127.0.0.1]:53276 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1mQaKb-0007hS-5n for submit@debbugs.gnu.org; Wed, 15 Sep 2021 15:12:29 -0400 Received: from lists.gnu.org ([209.51.188.17]:36540) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1mQaKY-0007hK-Na for submit@debbugs.gnu.org; Wed, 15 Sep 2021 15:12:27 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:45112) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mQaKY-0005FF-HH for bug-guile@gnu.org; Wed, 15 Sep 2021 15:12:26 -0400 Received: from mail-vk1-xa32.google.com ([2607:f8b0:4864:20::a32]:40663) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1mQaKX-0006rI-1b for bug-guile@gnu.org; Wed, 15 Sep 2021 15:12:26 -0400 Received: by mail-vk1-xa32.google.com with SMTP id 3so1417166vkg.7 for ; Wed, 15 Sep 2021 12:12:24 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=mime-version:from:date:message-id:subject:to; bh=T4VMsC5sUyvzdbSXMAIL+OsUjHfRR6b82MtZn4Zk0S0=; b=ivF4+zAdm5/Iu0+TW/LvqmQbcsncHP9INzkRHd5klU+zeTxokQk6YhpHV8xk8qElL0 5XC6xXAnaVhC+ojyULoXm9RKZqoqZ1YL4OekgwGnGagSeVToVq8DxVATmYvt2j+9GmiI +yEBU7sMdKQ6K3Dja9pgLB7l5jVa4dgkl/Kjuureqxncui7PVy7DEoS7gT0B9zGc5Xxb bZILtwOGeDgrzOkErZ16KAdCIGQ6gmz0GpuOBHe5fcMt45CTAokswH20E/B30IHfR/6i qHpMExtD8R78jooOo2eGlVh4EX8LZ2XALBctLQ/wKT7m7ZsxxObov4UF9ARpy5gJBs6b g6+w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:mime-version:from:date:message-id:subject:to; bh=T4VMsC5sUyvzdbSXMAIL+OsUjHfRR6b82MtZn4Zk0S0=; b=g7y8UwICphESE+KG4EayxFgnumob9BZZ6LeDUReMjIVn0r6M9N/5/fEtoLM7yCFPCV P9+R1g6FkmSKONbWZlUETAeipkSyneFslxxJ2yR0akFisx+6lDvnaopqyd69gGmZHSw4 qvAMs4KdvooXqfcnKv6MfwpJG8CvX4OfHyFvt9T6k8IfTs0U2oZQOzL7LryUxK5FKy05 enUNrBjQukh9eGcP0BIIl6wBznNDBE//2bE2huoamlV7Zx2l2M7M+sQmIoHLcYqZ8Qu4 cN+xY81DadtIGOYmWL+4+UDRJpTrq8NTpWYGhtNnVph4o/n18PymkJogOKR2FDnSyXwh PzrA== X-Gm-Message-State: AOAM532nPiLby2w6AABZX0g1hDl8n7xXPtrJlqP501ZmBEqTbjoPKYtW gT3qAlMTzXFht+PC/4pY15iwkfTH72BVjCI7FYlqe5Zj9uk= X-Google-Smtp-Source: ABdhPJxzNhngUpsfRhUOe1PVltYrNr84OYpijqPCwBOSWfFNhBa5x2Led/Kil29bXi/HsOv7cc4LcMC/eBpMrVivW64= X-Received: by 2002:a1f:2b14:: with SMTP id r20mr1316834vkr.13.1631733143921; Wed, 15 Sep 2021 12:12:23 -0700 (PDT) MIME-Version: 1.0 From: Stefan Israelsson Tampe Date: Wed, 15 Sep 2021 21:12:13 +0200 Message-ID: Subject: number overflow To: bug-guile@gnu.org Content-Type: multipart/alternative; boundary="00000000000069667e05cc0d7af4" Received-SPF: pass client-ip=2607:f8b0:4864:20::a32; envelope-from=stefan.itampe@gmail.com; helo=mail-vk1-xa32.google.com X-Spam_score_int: -1 X-Spam_score: -0.2 X-Spam_bar: / X-Spam_report: (-0.2 / 5.0 requ) BAYES_40=-0.001, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, FREEMAIL_FROM=0.001, HTML_MESSAGE=0.001, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-Spam-Score: -1.3 (-) X-Debbugs-Envelope-To: submit X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -2.3 (--) --00000000000069667e05cc0d7af4 Content-Type: text/plain; charset="UTF-8" This does not compile on guile 3.0.7, (define (f . l) (let lp2 ((i 0) (s 0) (l l)) (if (and (pair? l) (< i 64)) (lp2 (+ i 1) (if (car l) (logior (ash 1 i) s) s) (cdr l)) s))) While compiling expression: Throw to key `numerical-overflow' with args `("ash" "Numerical ove rflow" #f #f)'. --00000000000069667e05cc0d7af4 Content-Type: text/html; charset="UTF-8" Content-Transfer-Encoding: quoted-printable
This does not compile on guile 3.0.7,

(define (f . l)
=C2=A0= (let lp2 ((i 0) (s 0) (l l))
=C2=A0 =C2=A0 (if (and (pair? l) (< i 6= 4))
=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0(lp2 (+ i 1) (if (car l) (logior (= ash 1 i) s) s) (cdr l))
=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0s)))
<= br>
While = compiling expression:
Throw to key `numerical-overflow' with args = `("ash" "Numerical ove
rflow" #f #f)'.<= br>
--00000000000069667e05cc0d7af4-- From debbugs-submit-bounces@debbugs.gnu.org Thu Nov 04 15:12:22 2021 Received: (at 50609) by debbugs.gnu.org; 4 Nov 2021 19:12:22 +0000 Received: from localhost ([127.0.0.1]:43602 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1mii9u-0006Wa-40 for submit@debbugs.gnu.org; Thu, 04 Nov 2021 15:12:22 -0400 Received: from mta-10-3.privateemail.com ([198.54.127.62]:39850) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1mii9s-0006WK-2V for 50609@debbugs.gnu.org; Thu, 04 Nov 2021 15:12:20 -0400 Received: from mta-10.privateemail.com (localhost [127.0.0.1]) by mta-10.privateemail.com (Postfix) with ESMTP id 0FBD3180009E for <50609@debbugs.gnu.org>; Thu, 4 Nov 2021 15:12:14 -0400 (EDT) Received: from [192.168.1.105] (unknown [10.20.151.235]) by mta-10.privateemail.com (Postfix) with ESMTPA id 4CA7518000A4 for <50609@debbugs.gnu.org>; Thu, 4 Nov 2021 15:12:13 -0400 (EDT) From: lloda Content-Type: multipart/mixed; boundary="Apple-Mail=_E61CEFE1-69F8-4DCA-AC02-3AED80524B90" Mime-Version: 1.0 (Mac OS X Mail 13.4 \(3608.120.23.2.7\)) Subject: Re: number overflow Message-Id: Date: Thu, 4 Nov 2021 20:12:10 +0100 To: 50609@debbugs.gnu.org X-Mailer: Apple Mail (2.3608.120.23.2.7) X-Virus-Scanned: ClamAV using ClamSMTP X-Spam-Score: 3.7 (+++) X-Spam-Report: Spam detection software, running on the system "debbugs.gnu.org", has NOT identified this incoming email as spam. The original message has been attached to this so you can view it or label similar future email. If you have any questions, see the administrator of that system for details. Content preview: Not quite comfortable poking around in the compiler, but find a patch attached. I also found this related bug: https://debbugs.gnu.org/cgi/bugreport.cgi?bug=32644. Content analysis details: (3.7 points, 10.0 required) pts rule name description ---- ---------------------- -------------------------------------------------- -0.0 SPF_PASS SPF: sender matches SPF record -0.0 RCVD_IN_DNSWL_NONE RBL: Sender listed at https://www.dnswl.org/, no trust [198.54.127.62 listed in list.dnswl.org] -0.0 RCVD_IN_MSPIKE_H2 RBL: Average reputation (+2) [198.54.127.62 listed in wl.mailspike.net] 0.0 SPF_HELO_NONE SPF: HELO does not publish an SPF Record 3.7 FAKE_REPLY_B No description available. X-Debbugs-Envelope-To: 50609 X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: 2.7 (++) X-Spam-Report: Spam detection software, running on the system "debbugs.gnu.org", has NOT identified this incoming email as spam. The original message has been attached to this so you can view it or label similar future email. If you have any questions, see the administrator of that system for details. Content preview: Not quite comfortable poking around in the compiler, but find a patch attached. I also found this related bug: https://debbugs.gnu.org/cgi/bugreport.cgi?bug=32644. Content analysis details: (2.7 points, 10.0 required) pts rule name description ---- ---------------------- -------------------------------------------------- -0.0 RCVD_IN_MSPIKE_H2 RBL: Average reputation (+2) [198.54.127.62 listed in wl.mailspike.net] -0.0 RCVD_IN_DNSWL_NONE RBL: Sender listed at https://www.dnswl.org/, no trust [198.54.127.62 listed in list.dnswl.org] -0.0 SPF_PASS SPF: sender matches SPF record 0.0 SPF_HELO_NONE SPF: HELO does not publish an SPF Record -1.0 MAILING_LIST_MULTI Multiple indicators imply a widely-seen list manager 3.7 FAKE_REPLY_B No description available. --Apple-Mail=_E61CEFE1-69F8-4DCA-AC02-3AED80524B90 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset=us-ascii Not quite comfortable poking around in the compiler, but find a patch = attached. I also found this related bug: = https://debbugs.gnu.org/cgi/bugreport.cgi?bug=3D32644. --Apple-Mail=_E61CEFE1-69F8-4DCA-AC02-3AED80524B90 Content-Disposition: attachment; filename=0001-Limit-the-range-of-ash-round-ash-count-argument-to-I.patch Content-Type: application/octet-stream; x-unix-mode=0644; name="0001-Limit-the-range-of-ash-round-ash-count-argument-to-I.patch" Content-Transfer-Encoding: quoted-printable =46rom=20699919f181ea94ba00d392b49d07ed85e7535fcc=20Mon=20Sep=2017=20= 00:00:00=202001=0AFrom:=20Daniel=20Llorens=20=0ADate:=20= Thu,=204=20Nov=202021=2014:52:21=20+0100=0ASubject:=20[PATCH=201/2]=20= Limit=20the=20range=20of=20ash,=20round-ash=20count=20argument=20to=20= INT32=0A=0AThis=20avoids=20gmp=20aborting=20e.g.=20with=20(ash=201=20= (expt=202=2037)).=20The=20new=20limit=20is=0Asuch=20that=20(ash=201=20= (expt=2030))=20is=20accepted=20but=20(ash=201=20(expt=2031))=20throws.=0A= =0A*=20libguile/numbers.c=20(ash,=20round-ash):=20As=20stated.=0A*=20= test-suite/tests/numbers.test:=20Test=20a=20case=20known=20to=20make=20= gmp=20abort=20before.=0A---=0A=20libguile/numbers.c=20=20=20=20=20=20=20=20= =20=20=20=20|=2098=20+++++++++++++++--------------------=0A=20= test-suite/tests/numbers.test=20|=20=205=20+-=0A=202=20files=20changed,=20= 47=20insertions(+),=2056=20deletions(-)=0A=0Adiff=20--git=20= a/libguile/numbers.c=20b/libguile/numbers.c=0Aindex=20= 18bd22dbb..1f7785aa6=20100644=0A---=20a/libguile/numbers.c=0A+++=20= b/libguile/numbers.c=0A@@=20-5090,6=20+5090,8=20@@=20= round_right_shift_exact_integer=20(SCM=20n,=20long=20count)=0A=20=20=20=20= and=20moreover=20that=20they=20can=20be=20negated=20without=20overflow.=20= */=0A=20verify=20(SCM_MOST_NEGATIVE_FIXNUM=20>=3D=20LONG_MIN=20+=201=0A=20= =20=20=20=20=20=20=20=20&&=20SCM_MOST_POSITIVE_FIXNUM=20<=3D=20= LONG_MAX);=0A+/*=20the=20practicable=20limits=20are=20smaller=20*/=0A= +verify=20(INT32_MIN=20>=3D=20LONG_MIN=20&&=20INT32_MAX=20<=3D=20= LONG_MAX);=0A=20=0A=20SCM_DEFINE=20(scm_ash,=20"ash",=202,=200,=200,=0A=20= =20=20=20=20=20=20=20=20=20=20=20=20(SCM=20n,=20SCM=20count),=0A@@=20= -5110,35=20+5112,28=20@@=20SCM_DEFINE=20(scm_ash,=20"ash",=202,=200,=20= 0,=0A=20=09=20=20=20=20"@end=20lisp")=0A=20#define=20FUNC_NAME=20= s_scm_ash=0A=20{=0A-=20=20if=20(SCM_I_INUMP=20(n)=20||=20SCM_BIGP=20(n))=0A= -=20=20=20=20{=0A-=20=20=20=20=20=20long=20bits_to_shift;=0A-=0A-=20=20=20= =20=20=20if=20(SCM_I_INUMP=20(count))=20=20/*=20fast=20path,=20not=20= strictly=20needed=20*/=0A-=20=20=20=20=20=20=20=20bits_to_shift=20=3D=20= SCM_I_INUM=20(count);=0A-=20=20=20=20=20=20else=20if=20= (scm_is_signed_integer=20(count,=20LONG_MIN=20+=201,=20LONG_MAX))=0A-=20=20= =20=20=20=20=20=20/*=20We=20exclude=20LONG_MIN=20to=20ensure=20that=20= 'bits_to_shift'=20can=20be=0A-=20=20=20=20=20=20=20=20=20=20=20negated=20= without=20overflowing.=20*/=0A-=20=20=20=20=20=20=20=20bits_to_shift=20=3D= =20scm_to_long=20(count);=0A-=20=20=20=20=20=20else=20if=20(scm_is_false=20= (scm_positive_p=20(scm_sum=20(scm_integer_length=20(n),=0A-=20=20=20=20=20= =20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20= =20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20= count))))=0A-=20=20=20=20=20=20=20=20/*=20Huge=20right=20shift=20that=20= eliminates=20all=20but=20the=20sign=20bit=20*/=0A-=20=20=20=20=20=20=20=20= return=20scm_is_false=20(scm_negative_p=20(n))=0A-=20=20=20=20=20=20=20=20= =20=20?=20SCM_INUM0=20:=20SCM_I_MAKINUM=20(-1);=0A-=20=20=20=20=20=20= else=20if=20(scm_is_true=20(scm_zero_p=20(n)))=0A-=20=20=20=20=20=20=20=20= return=20SCM_INUM0;=0A-=20=20=20=20=20=20else=0A-=20=20=20=20=20=20=20=20= scm_num_overflow=20("ash");=0A-=0A-=20=20=20=20=20=20if=20(bits_to_shift=20= >=200)=0A-=20=20=20=20=20=20=20=20return=20left_shift_exact_integer=20= (n,=20bits_to_shift);=0A-=20=20=20=20=20=20else=20if=20(SCM_LIKELY=20= (bits_to_shift=20<=200))=0A-=20=20=20=20=20=20=20=20return=20= floor_right_shift_exact_integer=20(n,=20-bits_to_shift);=0A-=20=20=20=20=20= =20else=0A-=20=20=20=20=20=20=20=20return=20n;=0A-=20=20=20=20}=0A-=20=20= else=0A+=20=20if=20(!SCM_I_INUMP=20(n)=20&&=20!SCM_BIGP=20(n))=0A=20=20=20= =20=20SCM_WRONG_TYPE_ARG=20(SCM_ARG1,=20n);=0A+=20=20=0A+=20=20if=20= (scm_is_false=20(scm_positive_p=20(scm_sum=20(scm_integer_length=20(n),=0A= +=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20= =20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20count))))=0A= +=20=20=20=20/*=20Huge=20right=20shift=20that=20eliminates=20all=20but=20= the=20sign=20bit=20*/=0A+=20=20=20=20return=20scm_is_false=20= (scm_negative_p=20(n))=0A+=20=20=20=20=20=20?=20SCM_INUM0=20:=20= SCM_I_MAKINUM=20(-1);=0A+=20=20else=20if=20(scm_is_true=20(scm_zero_p=20= (n)))=0A+=20=20=20=20return=20SCM_INUM0;=0A+=20=20else=20if=20= (scm_is_signed_integer=20(count,=20INT32_MIN=20+=201,=20INT32_MAX))=20{=0A= +=20=20=20=20/*=20We=20exclude=20MIN=20to=20ensure=20that=20= 'bits_to_shift'=20can=20be=0A+=20=20=20=20=20=20=20negated=20without=20= overflowing,=20if=20INT32_MIN=20happens=20to=20be=20LONG_MIN=20*/=0A+=20=20= =20=20long=20bits_to_shift=20=3D=20scm_to_long=20(count);=0A+=20=20=20=20= if=20(bits_to_shift=20>=200)=0A+=20=20=20=20=20=20return=20= left_shift_exact_integer=20(n,=20bits_to_shift);=0A+=20=20=20=20else=20= if=20(SCM_LIKELY=20(bits_to_shift=20<=200))=0A+=20=20=20=20=20=20return=20= floor_right_shift_exact_integer=20(n,=20-bits_to_shift);=0A+=20=20=20=20= else=0A+=20=20=20=20=20=20return=20n;=0A+=20=20}=20else=0A+=20=20=20=20= scm_num_overflow=20("ash");=0A=20}=0A=20#undef=20FUNC_NAME=0A=20=0A@@=20= -5164,34=20+5159,27=20@@=20SCM_DEFINE=20(scm_round_ash,=20"round-ash",=20= 2,=200,=200,=0A=20=09=20=20=20=20"@end=20lisp")=0A=20#define=20FUNC_NAME=20= s_scm_round_ash=0A=20{=0A-=20=20if=20(SCM_I_INUMP=20(n)=20||=20SCM_BIGP=20= (n))=0A-=20=20=20=20{=0A-=20=20=20=20=20=20long=20bits_to_shift;=0A-=0A-=20= =20=20=20=20=20if=20(SCM_I_INUMP=20(count))=20=20/*=20fast=20path,=20not=20= strictly=20needed=20*/=0A-=20=20=20=20=20=20=20=20bits_to_shift=20=3D=20= SCM_I_INUM=20(count);=0A-=20=20=20=20=20=20else=20if=20= (scm_is_signed_integer=20(count,=20LONG_MIN=20+=201,=20LONG_MAX))=0A-=20=20= =20=20=20=20=20=20/*=20We=20exclude=20LONG_MIN=20to=20ensure=20that=20= 'bits_to_shift'=20can=20be=0A-=20=20=20=20=20=20=20=20=20=20=20negated=20= without=20overflowing.=20*/=0A-=20=20=20=20=20=20=20=20bits_to_shift=20=3D= =20scm_to_long=20(count);=0A-=20=20=20=20=20=20else=20if=20(scm_is_true=20= (scm_negative_p=20(scm_sum=20(scm_integer_length=20(n),=0A-=20=20=20=20=20= =20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20= =20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20= count)))=0A-=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20||=20= scm_is_true=20(scm_zero_p=20(n)))=0A-=20=20=20=20=20=20=20=20/*=20If=20N=20= is=20zero,=20or=20the=20right=20shift=20count=20exceeds=20the=20integer=0A= -=20=20=20=20=20=20=20=20=20=20=20length,=20the=20result=20is=20zero.=20= */=0A-=20=20=20=20=20=20=20=20return=20SCM_INUM0;=0A-=20=20=20=20=20=20= else=0A-=20=20=20=20=20=20=20=20scm_num_overflow=20("round-ash");=0A-=0A= -=20=20=20=20=20=20if=20(bits_to_shift=20>=200)=0A-=20=20=20=20=20=20=20=20= return=20left_shift_exact_integer=20(n,=20bits_to_shift);=0A-=20=20=20=20= =20=20else=20if=20(SCM_LIKELY=20(bits_to_shift=20<=200))=0A-=20=20=20=20=20= =20=20=20return=20round_right_shift_exact_integer=20(n,=20= -bits_to_shift);=0A-=20=20=20=20=20=20else=0A-=20=20=20=20=20=20=20=20= return=20n;=0A-=20=20=20=20}=0A-=20=20else=0A+=20=20if=20(!SCM_I_INUMP=20= (n)=20&&=20!SCM_BIGP=20(n))=0A=20=20=20=20=20SCM_WRONG_TYPE_ARG=20= (SCM_ARG1,=20n);=0A+=20=20=0A+=20=20if=20(scm_is_true=20(scm_negative_p=20= (scm_sum=20(scm_integer_length=20(n),=0A+=20=20=20=20=20=20=20=20=20=20=20= =20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20= =20=20=20=20=20=20=20=20count)))=0A+=20=20=20=20=20=20||=20scm_is_true=20= (scm_zero_p=20(n)))=0A+=20=20=20=20/*=20If=20N=20is=20zero,=20or=20the=20= right=20shift=20count=20exceeds=20the=20integer=0A+=20=20=20=20=20=20=20= length,=20the=20result=20is=20zero.=20*/=0A+=20=20=20=20return=20= SCM_INUM0;=0A+=20=20else=20if=20(scm_is_signed_integer=20(count,=20= INT32_MIN=20+=201,=20INT32_MAX))=20{=0A+=20=20=20=20/*=20We=20exclude=20= MIN=20to=20ensure=20that=20'bits_to_shift'=20can=20be=0A+=20=20=20=20=20=20= =20negated=20without=20overflowing,=20if=20INT32_MIN=20happens=20to=20be=20= LONG_MIN=20*/=0A+=20=20=20=20long=20bits_to_shift=20=3D=20scm_to_long=20= (count);=0A+=20=20=20=20if=20(bits_to_shift=20>=200)=0A+=20=20=20=20=20=20= return=20left_shift_exact_integer=20(n,=20bits_to_shift);=0A+=20=20=20=20= else=20if=20(SCM_LIKELY=20(bits_to_shift=20<=200))=0A+=20=20=20=20=20=20= return=20round_right_shift_exact_integer=20(n,=20-bits_to_shift);=0A+=20=20= =20=20else=0A+=20=20=20=20=20=20return=20n;=0A+=20=20}=20else=20=0A+=20=20= =20=20scm_num_overflow=20("round-ash");=0A=20}=0A=20#undef=20FUNC_NAME=0A= =20=0Adiff=20--git=20a/test-suite/tests/numbers.test=20= b/test-suite/tests/numbers.test=0Aindex=208f644874d..51263f0ac=20100644=0A= ---=20a/test-suite/tests/numbers.test=0A+++=20= b/test-suite/tests/numbers.test=0A@@=20-5466,7=20+5466,10=20@@=0A=20=20=20= =20=20=20=20=20=20(ash-variant=20-1=20(-=20(expt=202=201000))))=0A=20=20=20= =20=20=20=20(pass-if-exception=20"Huge=20left=20shift=20of=20non-zero=20= =3D>=20numerical=20overflow"=0A=20=20=20=20=20=20=20=20=20=20=20= exception:numerical-overflow=0A-=20=20=20=20=20=20=20=20(ash-variant=20= 123=20(expt=202=201000)))))=0A+=20=20=20=20=20=20=20=20(ash-variant=20= 123=20(expt=202=201000)))=0A+=20=20=20=20=20=20(pass-if-exception=20= "Shift=20large=20enough=20to=20cause=20gmp=20abort=20in=203.0.7"=0A+=20=20= =20=20=20=20=20=20=20=20exception:numerical-overflow=0A+=20=20=20=20=20=20= =20=20(ash-variant=201=20(expt=202=2037)))))=0A=20=0A=20=20=20= (test-ash-variant=20=20=20=20=20=20=20'ash=20=20=20=20=20=20=20ash=20= floor=20#f)=0A=20=20=20(test-ash-variant=20'round-ash=20round-ash=20= round=20#t)=0A--=20=0A2.33.1=0A=0A= --Apple-Mail=_E61CEFE1-69F8-4DCA-AC02-3AED80524B90 Content-Disposition: attachment; filename=0002-Avoid-ash-with-arguments-that-might-overflow-in-lang.patch Content-Type: application/octet-stream; x-unix-mode=0644; name="0002-Avoid-ash-with-arguments-that-might-overflow-in-lang.patch" Content-Transfer-Encoding: quoted-printable =46rom=2047f99500e68e40f34a1dab8b0350f32c2ed62d9d=20Mon=20Sep=2017=20= 00:00:00=202001=0AFrom:=20Daniel=20Llorens=20=0ADate:=20= Thu,=204=20Nov=202021=2016:02:42=20+0100=0ASubject:=20[PATCH=202/2]=20= Avoid=20ash=20with=20arguments=20that=20might=20overflow=20in=20= (language=0A=20cps=20types)=0A=0AFixes=20https://debbugs.gnu.org/50609=0A= =0A*=20module/languages/cps/types.scm=20(ulsh):=20As=20stated.=0A---=0A=20= module/language/cps/types.scm=20|=204=20+++-=0A=201=20file=20changed,=20= 3=20insertions(+),=201=20deletion(-)=0A=0Adiff=20--git=20= a/module/language/cps/types.scm=20b/module/language/cps/types.scm=0A= index=20d3be176bf..87c58d5bc=20100644=0A---=20= a/module/language/cps/types.scm=0A+++=20b/module/language/cps/types.scm=0A= @@=20-1444,7=20+1444,9=20@@=20minimum,=20and=20maximum."=0A=20=20=20=20=20= =20=20=20=20(define!=20result=20&s64=20&s64-min=20&s64-max))))=0A=20=0A=20= (define-type-inferrer=20(ulsh=20a=20b=20result)=0A-=20=20(if=20(<=3D=20= (ash=20(&max/u64=20a)=20(&max/u64=20b))=20&u64-max)=0A+=20=20(if=20(and=0A= +=20=20=20=20=20=20=20(or=20(zero?=20(&max/u64=20a))=20(<=20(&max/u64=20= b)=2064))=20;=20don't=20even=20try=0A+=20=20=20=20=20=20=20(<=3D=20(ash=20= (&max/u64=20a)=20(&max/u64=20b))=20&u64-max))=0A=20=20=20=20=20=20=20;;=20= No=20overflow;=20we=20can=20be=20precise.=0A=20=20=20=20=20=20=20= (define!=20result=20&u64=0A=20=20=20=20=20=20=20=20=20(ash=20(&min/0=20= a)=20(&min/0=20b))=0A--=20=0A2.33.1=0A=0A= --Apple-Mail=_E61CEFE1-69F8-4DCA-AC02-3AED80524B90 Content-Transfer-Encoding: 7bit Content-Type: text/plain; charset=us-ascii --Apple-Mail=_E61CEFE1-69F8-4DCA-AC02-3AED80524B90-- From debbugs-submit-bounces@debbugs.gnu.org Fri Nov 05 12:36:06 2021 Received: (at 50609-done) by debbugs.gnu.org; 5 Nov 2021 16:36:06 +0000 Received: from localhost ([127.0.0.1]:46972 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1mj2CD-00055v-Ue for submit@debbugs.gnu.org; Fri, 05 Nov 2021 12:36:06 -0400 Received: from mta-15-4.privateemail.com ([198.54.127.111]:50585) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1mj2CC-00055Q-Nd for 50609-done@debbugs.gnu.org; Fri, 05 Nov 2021 12:36:05 -0400 Received: from mta-15.privateemail.com (localhost [127.0.0.1]) by mta-15.privateemail.com (Postfix) with ESMTP id 2285E18000A6 for <50609-done@debbugs.gnu.org>; Fri, 5 Nov 2021 12:35:59 -0400 (EDT) Received: from [192.168.1.105] (unknown [10.20.151.235]) by mta-15.privateemail.com (Postfix) with ESMTPA id 9E4F6180009F for <50609-done@debbugs.gnu.org>; Fri, 5 Nov 2021 12:35:58 -0400 (EDT) From: lloda Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: quoted-printable Mime-Version: 1.0 (Mac OS X Mail 13.4 \(3608.120.23.2.7\)) Subject: Re: number overflow Message-Id: Date: Fri, 5 Nov 2021 17:35:56 +0100 To: 50609-done@debbugs.gnu.org X-Mailer: Apple Mail (2.3608.120.23.2.7) X-Virus-Scanned: ClamAV using ClamSMTP X-Spam-Score: 3.7 (+++) X-Spam-Report: Spam detection software, running on the system "debbugs.gnu.org", has NOT identified this incoming email as spam. The original message has been attached to this so you can view it or label similar future email. If you have any questions, see the administrator of that system for details. Content preview: I've applied the patch in c6b1171c6b5632ac04120f482af786444e17d3fe. Thanks for the report! Content analysis details: (3.7 points, 10.0 required) pts rule name description ---- ---------------------- -------------------------------------------------- -0.0 RCVD_IN_DNSWL_NONE RBL: Sender listed at https://www.dnswl.org/, no trust [198.54.127.111 listed in list.dnswl.org] -0.0 SPF_PASS SPF: sender matches SPF record 0.0 SPF_HELO_NONE SPF: HELO does not publish an SPF Record -0.0 RCVD_IN_MSPIKE_H3 RBL: Good reputation (+3) [198.54.127.111 listed in wl.mailspike.net] -0.0 RCVD_IN_MSPIKE_WL Mailspike good senders 3.7 FAKE_REPLY_B No description available. X-Debbugs-Envelope-To: 50609-done X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: 2.7 (++) X-Spam-Report: Spam detection software, running on the system "debbugs.gnu.org", has NOT identified this incoming email as spam. The original message has been attached to this so you can view it or label similar future email. If you have any questions, see the administrator of that system for details. Content preview: I've applied the patch in c6b1171c6b5632ac04120f482af786444e17d3fe. Thanks for the report! Content analysis details: (2.7 points, 10.0 required) pts rule name description ---- ---------------------- -------------------------------------------------- -0.0 RCVD_IN_MSPIKE_H3 RBL: Good reputation (+3) [198.54.127.111 listed in wl.mailspike.net] -0.0 RCVD_IN_DNSWL_NONE RBL: Sender listed at https://www.dnswl.org/, no trust [198.54.127.111 listed in list.dnswl.org] -0.0 SPF_PASS SPF: sender matches SPF record 0.0 SPF_HELO_NONE SPF: HELO does not publish an SPF Record -0.0 RCVD_IN_MSPIKE_WL Mailspike good senders -1.0 MAILING_LIST_MULTI Multiple indicators imply a widely-seen list manager 3.7 FAKE_REPLY_B No description available. I've applied the patch in c6b1171c6b5632ac04120f482af786444e17d3fe. = Thanks for the report! From unknown Thu Aug 14 21:52:05 2025 Received: (at fakecontrol) by fakecontrolmessage; To: internal_control@debbugs.gnu.org From: Debbugs Internal Request Subject: Internal Control Message-Id: bug archived. Date: Sat, 04 Dec 2021 12:24:05 +0000 User-Agent: Fakemail v42.6.9 # This is a fake control message. # # The action: # bug archived. thanks # This fakemail brought to you by your local debbugs # administrator