Hello,<br><br>It seems this bug has already been submitted:<br><a href="http://hackage.haskell.org/trac/ghc/ticket/2120">http://hackage.haskell.org/trac/ghc/ticket/2120</a><br><br>Thanks for the help.<br>__<br>Donnie Jones<br>
<br><div><span class="gmail_quote">On 3/14/08, <b class="gmail_sendername">Cale Gibbard</b> <<a href="mailto:cgibbard@gmail.com">cgibbard@gmail.com</a>> wrote:</span><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">
Here's the bug:<br> <br> {-# INLINE safeIndex #-}<br> safeIndex :: Ix i => (i, i) -> Int -> i -> Int<br> safeIndex (l,u) n i = let i' = unsafeIndex (l,u) i<br> in if (0 <= i') && (i' < n)<br>
then i'<br> else error "Error in array index"<br> <br> unsafeIndex here is just a function which transforms indices into Int<br> indices into the flat array and does no checking of validity. Then<br>
safeIndex simply checks if the result is nonnegative and less than the<br> size of the array. Whoops! The actual test to see if the index was<br> valid in the first place didn't actually get performed!<br> <br><br> - Cale<br>
<br><br> On 14/03/2008, Eric Mertens <<a href="mailto:emertens@gmail.com">emertens@gmail.com</a>> wrote:<br> > Smaller example of this behavior:<br> ><br> > > array ((0,0),(1,1)) [((1,1),6)] ! (0,3)<br>
> 6<br> ><br> > --<br> ><br> > Eric Mertens<br> ><br> > _______________________________________________<br> > Haskell-Cafe mailing list<br> > <a href="mailto:Haskell-Cafe@haskell.org">Haskell-Cafe@haskell.org</a><br>
> <a href="http://www.haskell.org/mailman/listinfo/haskell-cafe">http://www.haskell.org/mailman/listinfo/haskell-cafe</a><br> ><br> _______________________________________________<br> Haskell-Cafe mailing list<br>
<a href="mailto:Haskell-Cafe@haskell.org">Haskell-Cafe@haskell.org</a><br> <a href="http://www.haskell.org/mailman/listinfo/haskell-cafe">http://www.haskell.org/mailman/listinfo/haskell-cafe</a><br> </blockquote></div><br>