Skip to content
This repository was archived by the owner on Jan 9, 2019. It is now read-only.
This repository was archived by the owner on Jan 9, 2019. It is now read-only.

run-time crash when using a combination of unsafe core primitives (compiler error, most likely) #86

@marcomaggi

Description

@marcomaggi

The following program crashes at run-time:

#!r6rs
(import (vicare)
  (vicare checks)
  (vicare system $fx)
  (vicare system $strings))

(define ($string-reverse! str start past)
  (do ((i ($fxsub1 past) ($fxsub1 i))
       (j start          ($fxadd1 j)))
      (($fx<= i j)
       str)
    (let ((ci ($string-ref str i)))
      ($string-set! str i ($string-ref str j))
      ($string-set! str j ci))))

(check
    (let ((S (string-copy "ciao")))
      ($string-reverse! S 0 4)
      S)
  => "oaic")

the crash does not occur if we change some unsafe core primitive application with the corresponding safe core primitive. For example, changing $fx<= to fx<=? avoids the error.

Notice that the following code with vectors works fine:

(internal-body
  (define ($vector-reverse! str start past)
    (do ((i ($fxsub1 past) ($fxsub1 i))
         (j start          ($fxadd1 j)))
        (($fx<= i j)
         str)
      (let ((ci ($vector-ref str i)))
        ($vector-set! str i ($vector-ref str j))
        ($vector-set! str j ci))))

  (check
      (let ((S (vector-copy '#(c i a o))))
        ($vector-reverse! S 0 4)
        S)
    => '#(o a i c)))

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions