nhc98 bignum div/mod gives wrong answers or segmentation faults

Martin Guy <[email protected]> Thu, 28 Oct 2004 23:53:17 +0100
Newsgroups gmane.comp.lang.haskell.nhc.bugs
Message-ID <[email protected]>
------=_Part_1524_633780.1099003997380
Content-Type: text/plain; charset=US-ASCII
Content-Transfer-Encoding: 7bit
Content-Disposition: inline

Hi!
   I'm in the first month of translating my brain from mira to hs,
and seem to have come across an hnc98 bug: my app is the
famous infinite-precision scientific math library - see
http://freaknet.org/bignum - and while the hs version currently
has no known bugs under hugs, when I compile with nhc98
it gives me pi as 3.157..... while sqrt(2) gives a couple of
thousand correct decimal places and then segmentation faults.
Other calculations run ok.
   The problem only seems to occur in code that uses the
div/mod on Integers, so I'm assuming the problem is in that.

   I've trimmed down the sqrt2 example to a small source file
which is attached and obligingly continues to work under hugs
and dump core with nhc98. Unfortunately I don't have another
architecture than Linux/x86 to try it on - would someone check
whether it does the same on another system?
   I'm afraid that the wrong-answer of pi is rather hard to extract
into a self-contained fragment as it uses the infinite-precision
trig functions and they call in the rest of the world.

The system is Slackware Linux 9.0 (GCC 3.2.2) on Intel Pentium 3
(Coppermine) with 128MB RAM.
Hugs is hugs98 - November 2003 and nhc is nhc98-1.16
both compiled from source tarballs with no problems.

I'm online every day or so if there are turther tests I can run
to help out.

Blessings

   Martin Guy

------=_Part_1524_633780.1099003997380
Content-Type: application/octet-stream; name="s.hs"
Content-Transfer-Encoding: base64
Content-Disposition: attachment; filename="s.hs"

LS0gVGVzdCBwcm9ncmFtIHRoYXQgdGlja2xlcyBzdXNwZWN0ZWQgYnVnIGluIG5oYzk4J3MgSW50
ZWdlciBkaXYvbW9kIGNvZGUuCi0tIFNob3VsZCBvdXRwdXQgYWxsIHRoZSBkZWNpbWFsIHBsYWNl
cyBvZiBzcXJ0KDIpOiAxNDE0Li4KLS0JTWFydGluIEd1eSwgTmV3Y2FzdGxlLCBPY3RvYmVyIDIw
MDQuCgptb2R1bGUgTWFpbiB3aGVyZQoKaW1wb3J0IElPCS0t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ludGVnZXIgKHIyIGBtb2RgIGliYXNlKSkgOiBtX3NxcnQn
IChyMiAqIGliYXNlLCBtX3NxcnRfc2hpZnRpbiAoaGRfbzIsdGxfbzEpKQoJICB3aGVyZQoJICAo
cjIsaGRfbzIpID0gbV9zcXJ0X2xvb3AgKHIxLGhkX28xKQoJICBpYmFzZSA9IHRvSW50ZWdlciBi
YXNlCgotLSBJcyB0aGUgdmFsdWUgb2YgYSBtYW50aXNzYSBlcXVhbCB0byB6ZXJvCm1faXNfemVy
byBbXSA9IFRydWUKbV9pc196ZXJvIChhOngpID0gaWYgYSAvPSAwIHRoZW4gRmFsc2UgZWxzZSBt
X2lzX3plcm8geAoKLS0gU2hpZnQgYW5vdGhlciB0ZXJtIG9mIHRoZSBvcGVyYW5kIGludG8gdGhl
IGNhbGN1bGF0aW9uLgptX3NxcnRfc2hpZnRpbiA6OiAoSW50ZWdlciwgW0ludF0pIC0+IChJbnRl
Z2VyLCBbSW50XSkKbV9zcXJ0X3NoaWZ0aW4gKGEsYjp4KSA9IChhICogc3FyX2Jhc2UgKyB0b0lu
dGVnZXIgYiwgeCkKbV9zcXJ0X3NoaWZ0aW4gKGEsW10pID0gKGEgKiBzcXJfYmFzZSwgW10pCgpz
cXJfYmFzZSA9IHRvSW50ZWdlciAoYmFzZSAqIGJhc2UpCgptX3NxcnRfbG9vcCA6OiAoSW50ZWdl
cixJbnRlZ2VyKSAtPiAoSW50ZWdlcixJbnRlZ2VyKQptX3NxcnRfbG9vcCBybwoJPSB1bnRpbCBz
cXJ0X2xvb3BfZG9uZSBzcXJ0X2xvb3BfYm9keSBybwoJICB3aGVyZQoJICBzcXJ0X2xvb3BfZG9u
ZSAociwgbykgPSAyKnIgPj0gbwktLSB3YXM6IDIqcisxID4gbwoJICBzcXJ0X2xvb3BfYm9keSAo
ciwgbykgPSAocisxLCBvIC0gKDIqcisxKSkK
------=_Part_1524_633780.1099003997380
Content-Type: text/plain; charset="us-ascii"
MIME-Version: 1.0
Content-Transfer-Encoding: 7bit
Content-Disposition: inline

_______________________________________________
Nhc-bugs mailing list
[email protected]
http://www.haskell.org/mailman/listinfo/nhc-bugs

------=_Part_1524_633780.1099003997380--