[Haskell-cafe] Maybe a compiler bug?

Daniel Fischer daniel.is.fischer at web.de
Tue Jan 6 14:48:51 EST 2009


Am Dienstag, 6. Januar 2009 18:32 schrieb Murray Gross:
> My last note had an error in it, and the code originally sent to the list
> should be ignored. I have attached the current version of the code, and
> here is some further information (the behavior is different, by the way,
> but still apparently wrong).
>
> I have attached the current version of the program, which behaves
> slightly differently from the version originally sent.
>
> I am running ghc 6.6, gcc 4.1.2, g++ 4.1.1, on Debian Linux. The compile
> lines are ghc -threaded solve.hs or ghc -threaded -O2 solve.hs. The
> execution line is ./a.out, which should give me single-threaded execution.
>
> Ignore the output on stdout; it is the same for both versions.
>
> On stderr, the unoptimized version of the attached code gives me both
> "fail" and "goOn" (see lines #150 and #153). The optimized version gives
> me only "goOn." I think that both should give me both "fail" and "goOn."

I get one "fail" and many "goOn" with optimisation using both, ghc-6.6 and 
ghc-6.8.3. That should indeed be so, because with optimisation, the branch

else trace "fail" []

is only evaluated once, the result ([]) being reused. Without optimisation, 
that branch is re-evaluated every time it is hit, so many "fail" are printed.

>
> Were circumstances different, I might suspect that laziness and
> optimization had something to do with this. However, earlier tests showed
> inconsistency between the result of the test in gTst3 and the code where
> the value of gTst3 is used.

Could you elaborate? I couldn't find an inconsistency using your previous 
code, it behaved as it should (until I ^C-ed it).

HTH,
Daniel


More information about the Haskell-Cafe mailing list