Opened 11 years ago

Last modified 9 years ago

#39 new defect

Missing bounds checks.

Reported by: Ben Lippmeier Owned by:
Priority: normal Milestone:
Component: repa Version: 3.2.2
Keywords: Cc:

Description

> let arr = fromListUnboxed (Z :. 3 :. 5) [1..15] :: Array U DIM2 Int
> arr ! (Z:.2:.4 :: DIM2) 
15

> reshape (Z:.15) arr ! (Z:.14 :: DIM1)
15

> reshape (Z:.15) arr ! (Z:.15 :: DIM1)
1076040336

> reshape (Z:.15) arr ! (Z:.(-15) :: DIM1)
140454916268033

> (fromListUnboxed (Z :. 10) [1..10] :: Array U DIM1 Int) ! (Z:.10 :: DIM1)
*** Exception: ./Data/Vector/Generic.hs:244 ((!)): index out of bounds (10,10)

Change History (3)

comment:1 Changed 10 years ago by Ben Lippmeier

The extract function is also unsafe.

ghci> let a = fromListUnboxed (ix2 4 4) [(1::Int)..16]
ghci> computeUnboxedS $ extract (ix2 2 2) (ix2 3 3) a
AUnboxed ((Z :. 3) :. 3) (fromList [11,12,13,15,16,139639468003248,139639468003248,2,3])

comment:2 Changed 9 years ago by Ben Lippmeier

Milestone: 4.0.0

comment:3 Changed 9 years ago by Ben Lippmeier

Component: libraryrepa
Note: See TracTickets for help on using tickets.