Re: [racket-dev] Inconsistent behavior when doing bitwise arithmetic

2016-10-14 Thread Gustavo Massaccesi
> Those numbers look like pointers interpreted as fixnums Yes. The optimizer thought that the result of (bitwise-and num -2) was a fixnum, so it changed (bitwise-ior (bitwise-and num -2) 0) to (unsafe-fxior (bitwise-and num -2) 0) All the pointers are even (actually a multiple of 4 in 32

Re: [racket-dev] Inconsistent behavior when doing bitwise arithmetic

2016-10-14 Thread Vincent St-Amour
Those numbers look like pointers interpreted as fixnums. So my guess as to why they differ so much is that between each operation, you call `printf`, which allocates enough to claim the addresses between, e.g., 70112357026588 and 70112357038692. So that next time around the loop, the result of

Re: [racket-dev] Inconsistent behavior when doing bitwise arithmetic

2016-10-14 Thread peter . samarin
Do you have any guess why the resulting numbers vary so much? On Thursday, October 13, 2016 at 7:20:47 PM UTC+2, mflatt wrote: > > 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.

Re: [racket-dev] Inconsistent behavior when doing bitwise arithmetic

2016-10-13 Thread John Boyle
I can confirm weird behavior (and I get different weird results): Welcome to Racket v6.5. > (define num #x) (for ([i 5]) (printf "~a~n" (bitwise-ior (bitwise-and num -2) 0))) 2192618128 2192618180 2192618200 2192618668 2192618688 > (for ([i 5]) (printf "~a~n" (bitwise-ior