Re: coredump on innocent code

Ross Paterson <[email protected]>
Newsgroups gmane.comp.lang.haskell.hugs.bugs
Message-ID <[email protected]>
On Thu, Sep 08, 2005 at 04:00:47PM +0000, [email protected] wrote:
> $ cat bug.hs
> main = print (let (x,(q,_)) = (1,divMod x x) in q)
> $ runhugs bug.hs
> Illegal instruction (core dumped)

Not entirely innocent: demand for x also causes evaluation of the second
pair, which depends on x: an infinite loop.  The correct version is

	main = print (let (x,~(q,_)) = (1,divMod x x) in q)

Unfortunately, it's a known bug that some infinite loops cause Hugs to
overrun the C stack, crashing the program.  (This is caught under Windows,
but not Unix.)
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.