haskell - unsafeRead causing stack overflow -
here's code bounds checks @ ideone.
it runs no out of bounds error.
in this code, on line 34 have changed on readarray unsaferead, , still compiles, crashes stack overflow.
is ghc bug or have done wrong?
unsaferead uses 0-based indices, have either adjust index reading,
elem <- unsaferead arr (i-1) or, better, allocate array least index of 0
arr <- newarray (0,upperbound) maxbound as is, unsaferead reads wrong place in array.
unrelated: suspect ideone uses 32-bit ghc, better don't run code upperbound > 100000 there.
Comments
Post a Comment