JuliaCollections / DataStructures.jl

Julia implementation of Data structures
https://juliacollections.github.io/DataStructures.jl/latest/
MIT License
694 stars 247 forks source link

Tests integer overflow on 32-bit #218

Open simonbyrne opened 8 years ago

simonbyrne commented 8 years ago

This line has an integer overflow on 32-bit machines, causing tests to fail.

cf https://github.com/JuliaLang/julia/issues/18741

Probably a good idea to switch on Appveyor, as that seems to be the most reliable way to test 32-bit builds

StephenVavasis commented 8 years ago

I am the author of that code. It sets up a large "Sieve of Eratosthenes" using SortedSets and SortedDicts to exercise the code for adding and deleting entries in BalancedTree32.jl. This code in BalancedTree23.jl has many branches because there are many cases; the leaf could be a 2-node; it could be a 3-node; there could be 3-nodes all the way to the top of the search tree, etc. I wrote my own code coverage tool (https://github.com/StephenVavasis/microcoverage) that checks coverage of every branch (i.e., every operand of ? :, && and ||) of every expression of every statement, and I discovered that I need a fairly large sieve in order to hit all of the branches. I never tested this code on a 32-bit machine.

So I propose as a fix: Line 345 of the indicated file should be replaced by:

N = myplatform_is_32_bit? 500 : 5000

Line 562 may need a similar patch.

I don't know the correct way to code the predicate: "my_platform_is_32_bit".

On a related note, is there a "standard" way to test coverage of every branch of the ?:, && and || operands?

simonbyrne commented 8 years ago

I don't know the correct way to code the predicate: "my_platform_is_32_bit".

Either Sys.WORD_SIZE == 32 or Int == Int32 should work.