[3.0.0] Compiler mishandles literal bignums passed to ‘ash’

  • Open
  • quality assurance status badge
Details
2 participants
  • lloda
  • Ludovic Courtès
Owner
unassigned
Submitted by
Ludovic Courtès
Severity
normal
L
L
Ludovic Courtès wrote on 6 Mar 2020 15:00
(address . bug-guile@gnu.org)
8736aloa6a.fsf@gnu.org
Hello,

Consider this:

Toggle snippet (27 lines)
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"

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

Ludo’.
L
?