bug#39947: [3.0.0] Compiler mishandles literal bignums passed to ‘ash’

Ludovic Courtès <[email protected]>
Newsgroups gmane.lisp.guile.bugs
Message-ID <[email protected]>
Hello,

Consider this:

--8<---------------cut here---------------start------------->8---
scheme@(guile-user)> (compile `(ash 1 ,(expt 2 64)) #:to 'value)
ice-9/boot-9.scm:1669:16: In procedure raise-exception:
In procedure bytevector-u32-native-set!: Argument 3 out of range: 4294967296

Entering a new prompt.  Type `,bt' for a backtrace or `,q' to continue.
scheme@(guile-user) [1]> ,bt
In system/base/compile.scm:
    255:6  8 (compile _ #:from _ #:to _ #:env _ #:opts _)
   183:32  7 (compile-fold _ _ #<module (#{ g251}#) 7f5f08f38500> ())
In language/cps/compile-bytecode.scm:
     50:2  6 (emit-bytecode #<intmap 0-6> #<module (#{ g251}#) 7f5f08f38500> ())
   686:23  5 (_ _ _ _)
In language/cps/intmap.scm:
    519:5  4 (visit-branch #(#<cps (kfun () 0 6 1)> #<cps (kclause (() () #f () #f) 2)> #<cps (kargs () () (…> …) …)
In language/cps/compile-bytecode.scm:
    50:34  3 (_ 3 #<cps (kargs (arg) (1) (continue 4 (primcall load-u64 18446744073709551616)))> _)
    232:9  2 (compile-cont _ _)
In system/vm/assembler.scm:
    800:0  1 (encode-X8_S24-AU32-BU32 #<<asm> buf: #u32(1 0 1048845 393528 62 2020111201 1835364909 560297583 1…> …)
In ice-9/boot-9.scm:
  1669:16  0 (raise-exception _ #:continuable? _)
scheme@(guile-user) [1]> %host-type
$2 = "x86_64-unknown-linux-gnu"
scheme@(guile-user) [1]> (version)
$3 = "3.0.0"
--8<---------------cut here---------------end--------------->8---

It seems to me that the problem is that the compiler emits
‘lsh/immediate’ (which expects a u64) instead of ‘lsh’.

Ludo’.
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.