Thanks for the report!
This is a bug in the optimizer's handling of `bitwise-and`, where I
made it assume a fixnum result if either argument is a fixnum. That's
obviously not correct if the fixnum is negative. I'll push a repair.
The difference you see when running in a module is because the
optimizer constant-folds the calculation, so there's no `bitwise-and`
call left to make incorrect assumptions about.
At Thu, 13 Oct 2016 09:17:52 -0700 (PDT), peter.sama...@gmail.com wrote:
> Hi all,
> I get a weird behavior when using bitwise-ior and bitwise-and with large
> numbers. Tested on 2 machines (racket 6.6, Ubuntu 16.04 and 14.04):
> Here is the test example:
> #lang racket
> (define num #xffffffffffffffff) ;; remove one f, and the results are fine
> in both cases
> (for ([i 5])
> (printf "~a~n" (bitwise-ior (bitwise-and num -2) 0)))
> When run from DrRacket using ctr+r, it works properly:
> When pasted into DrRacket's REPL (or run from command line via "racket
> random-bug.rkt"), the code does not only produce wrong result, but also
> seems to be counting something :)
> Removing one "f" from the test number results in correct behavior in both
> Very large numbers are are reduced to the same range (around 54 bits).
> Replacing the expression (bitwise-and num -2) by the corresponding number
> it computes results in correct behavior.
> You received this message because you are subscribed to the Google Groups
> "Racket Developers" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to racket-dev+unsubscr...@googlegroups.com.
> To post to this group, send email to email@example.com.
> To view this discussion on the web visit
> For more options, visit https://groups.google.com/d/optout.
You received this message because you are subscribed to the Google Groups
"Racket Developers" group.
To unsubscribe from this group and stop receiving emails from it, send an email
To post to this group, send email to firstname.lastname@example.org.
To view this discussion on the web visit
For more options, visit https://groups.google.com/d/optout.