Changes between Initial Version and Version 3 of Ticket #37
- Timestamp:
- 10/15/06 08:22:30 (7 years ago)
Legend:
- Unmodified
- Added
- Removed
- Modified
-
Ticket #37
- Property owner changed from nobody to ross
- Property status changed from new to assigned
-
Ticket #37 – description
initial v3 1 1 Hi, 2 2 3 a few days ago I wrote a program which handles my own integers. Then I 4 check my own implementation against the normal Int implementation in Hugs. 3 a few days ago I wrote a program which handles my own integers. Then I check my own implementation against the normal Int implementation in Hugs. 5 4 Thereby I wonder about inequality of Ints which are definitely equal. 6 5 7 This is a test program I wrote after I recognized that hugs 8 has probably a bug in the inequality check of Ints. 9 6 This is a test program I wrote after I recognized that hugs has probably a bug in the inequality check of Ints. 7 {{{ 8 data MInt = Zero | Succ MInt | Pred MInt deriving Show 10 9 11 data MInt = Zero | Succ MInt | Pred MInt deriving Show 10 tn :: Int -> MInt 11 tn x | x<0 = Pred (tn (x+1)) 12 tn 0 = Zero 13 tn (n+1) = Succ (tn n) 12 14 13 tn :: Int -> MInt14 tn x | x<0 = Pred (tn (x+1)) 15 tn 0 = Zero 16 tn (n+1) = Succ (tn n) 15 ti :: MInt -> Int 16 ti Zero = 0 17 ti (Succ x) = 1+(ti x) 18 ti (Pred x) = (ti x) -1 17 19 18 ti :: MInt -> Int 19 ti Zero = 0 20 ti (Succ x) = 1+(ti x) 21 ti (Pred x) = (ti x) -1 20 testi :: (MInt -> MInt -> MInt) -> (Int -> Int -> Int) -> Int -> Int -> Bool 21 testi f g x y = (ti (f (tn x) (tn y))) /= (g x y) 22 22 23 testi :: (MInt -> MInt -> MInt) -> (Int -> Int -> Int) -> Int -> Int -> Bool 24 testi f g x y = (ti (f (tn x) (tn y))) /= (g x y) 23 myMul x y = tn ((ti x) * (ti y)) 25 24 26 myMul x y = tn ((ti x) * (ti y)) 25 test = [(x,y,ti (myMul (tn x) (tn y)),x * y)| 26 x<-[-100..100], 27 y<-([-100..(-1)]++[1..100]),(testi myMul (*) x y) ] 28 }}} 29 The list "test" should be empty in any case but unfortunately hugs returns this (copy of the console): 30 {{{ 31 __ __ __ __ ____ ___ _________________________________________ 32 || || || || || || ||__ Hugs 98: Based on the Haskell 98 standard 33 ||___|| ||__|| ||__|| __|| Copyright (c) 1994-2003 34 ||---|| ___|| World Wide Web: http://haskell.org/hugs 35 || || Report bugs to: hugs-bugs@haskell.org 36 || || Version: November 2003 _________________________________________ 27 37 28 test = [(x,y,ti (myMul (tn x) (tn y)),x * y)| 29 x<-[-100..100], 30 y<-([-100..(-1)]++[1..100]),(testi myMul (*) x y) ] 38 Haskell 98 mode: Restart with command line option -98 to enable extensions 31 39 32 the list "test" should be empty in any case 33 but unfortunately hugs returns this (copy of the console): 34 35 __ __ __ __ ____ ___ _________________________________________ 36 || || || || || || ||__ Hugs 98: Based on the Haskell 98 standard 37 ||___|| ||__|| ||__|| __|| Copyright (c) 1994-2003 38 ||---|| ___|| World Wide Web: http://haskell.org/hugs 39 || || Report bugs to: hugs-bugs@haskell.org 40 || || Version: November 2003 _________________________________________ 41 42 Haskell 98 mode: Restart with command line option -98 to enable extensions 43 44 Type :? for help 45 Main> test 46 [(-100,80,-8000,-8000),(-100,99,-9900,-9900), 47 (-99,58,-5742,-5742),(-99,83,-8217,-8217), 48 (-98,71,-6958,-6958),(-98,86,-8428,-8428), 49 (-97,46,-4462,-4462),(-97,87,-8439,-8439), 50 (-96,76,-7296,-7296),(-95,88,-8360,-8360),(-94,73,-6862,-6862) 51 ERROR - Control stack overflow 52 Main> 53 54 I have checked this program with Hugs on different plattforms: 55 Gentoo Linux x86 64-Bit and Suse Linux 32-Bit. On both plattforms 56 the same bug occurs with different Ints for each run (i.e. the list 57 contains different tuples). I have also checked my program with 40 Type :? for help 41 Main> test 42 [(-100,80,-8000,-8000),(-100,99,-9900,-9900), 43 (-99,58,-5742,-5742),(-99,83,-8217,-8217), 44 (-98,71,-6958,-6958),(-98,86,-8428,-8428), 45 (-97,46,-4462,-4462),(-97,87,-8439,-8439), 46 (-96,76,-7296,-7296),(-95,88,-8360,-8360),(-94,73,-6862,-6862) 47 ERROR - Control stack overflow 48 Main> 49 }}} 50 I have checked this program with Hugs on different plattforms: Gentoo Linux x86 64-Bit and Suse Linux 32-Bit. On both platforms the same bug occurs with different Ints for each run (i.e. the list contains different tuples). I have also checked my program with 58 51 other Haskell implementations and there it returns an empty list 59 52 as expected. … … 63 56 64 57 P.S.: We have tested Sep2006 with similar results: 58 {{{ 65 59 __ __ __ __ ____ ___ _________________________________________ 66 60 || || || || || || ||__ Hugs 98: Based on the Haskell 98 standard … … 75 69 Main> :e 76 70 Main> test 77 [(-100,90,-9000,-9000),(-98,40,-3920,-3920),(-97,63,-6111,-6111),(-97,69,-6693,- 6693)71 [(-100,90,-9000,-9000),(-98,40,-3920,-3920),(-97,63,-6111,-6111),(-97,69,-6693,-6693) 78 72 ERROR - Control stack overflow 73 }}}
