[GHC] #5438: Wrong result for element check
GHC
cvs-ghc at haskell.org
Mon Aug 29 11:12:28 CEST 2011
#5438: Wrong result for element check
----------------------------------+-----------------------------------------
Reporter: daniel.is.fischer | Owner:
Type: bug | Status: new
Priority: normal | Component: Data Parallel Haskell
Version: 7.0.4 | Keywords:
Testcase: | Blockedby:
Os: Unknown/Multiple | Blocking:
Architecture: Unknown/Multiple | Failure: Incorrect result at runtime
----------------------------------+-----------------------------------------
On the [http://haskell.org/pipermail/beginners/2011-August/008422.html
beginners] list, Luca Ciciriello reported that
{{{
{-# LANGUAGE PArr #-}
{-# OPTIONS -fdph-seq #-}
module Main where
import Control.Parallel
import GHC.PArr
parArr :: [:String:]
parArr = [: "1", "2", "3", "4" :]
isElement :: String -> Bool
isElement x = x `elemP` parArr
main :: IO ()
main = do
putStrLn $ (show . isElement) "5"
}}}
prints True. Obviously it should print False. I've replicated the
behaviour with 7.0.4 and 6.10.4 on 64-bit linux (Luca tested on Mac and
Windows).
As far as I can tell, elemP no longer exists in dph, so I had to modify to
test with HEAD, and
{{{
{-# LANGUAGE ParallelArrays #-}
{-# OPTIONS -fdph-seq #-}
module Main where
import GHC.PArr
import Data.Array.Parallel
parArr :: [:String:]
parArr = [: "1", "2", "3", "4" :]
isElement :: String -> Bool
isElement x = x `elemP1` parArr
where
elemP1 :: Eq a => a -> [:a:] -> Bool
elemP1 v ar = lengthP (filterP (== v) ar) /= 0
main :: IO ()
main = do
putStrLn $ (show . isElement) "5"
}}}
also prints True with HEAD, but prints False with 6.10.4 and 7.0.4 (with
the necessary modifications, !ParallelArrays -> PArr, don't import
Data.Array.Parallel).
--
Ticket URL: <http://hackage.haskell.org/trac/ghc/ticket/5438>
GHC <http://www.haskell.org/ghc/>
The Glasgow Haskell Compiler
More information about the Glasgow-haskell-bugs
mailing list