<div dir="ltr">I think this is a bug. It also seems to impact explicitly sized types:<div><br></div><div><div>Prelude Data.Int> (minBound::Int8) `quot` (-1)</div><div>*** Exception: arithmetic overflow</div><div>Prelude Data.Int> (minBound::Int16) `quot` (-1)</div>
<div>*** Exception: arithmetic overflow</div></div><div><br></div><div>You should definitely report it. I think there's a pending release of GHC, so they might be able to fix it shortly.</div><div><br></div><div>-Levent.</div>
</div><div class="gmail_extra"><br><br><div class="gmail_quote">On Thu, Jan 23, 2014 at 10:33 PM, Rob Leslie <span dir="ltr"><<a href="mailto:rob@mars.org" target="_blank">rob@mars.org</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
Greetings,<br>
<br>
I have a question about arithmetic overflow in Haskell -- actually, probably specifically in GHC.<br>
<br>
It’s my understanding from the Haskell 2010 Language Report that “The results of exceptional conditions (such as overflow or underflow) on the fixed-precision numeric types [e.g. Int] are undefined; an implementation may choose error (⊥, semantically), a truncated value, or a special value such as infinity, indefinite, etc.”<br>

<br>
In the documentation for Data.Int from the current release of the Haskell Platform, I read that “All arithmetic is performed modulo 2^n, where n is the number of bits in the type.”<br>
<br>
However, there seems to be at least one exception to this promise, namely:<br>
<br>
  λ> (minBound :: Int) `quot` (-1)<br>
  *** Exception: arithmetic overflow<br>
<br>
Is this a bug?<br>
<br>
More specifically, is it intended to be safe to rely on the modulo arithmetic behavior of GHC in spite of the Language Report? And if so, should the above witnessed behavior still be expected?<br>
<br>
Thanks,<br>
<span class="HOEnZb"><font color="#888888"><br>
--<br>
Rob Leslie<br>
<a href="mailto:rob@mars.org">rob@mars.org</a><br>
<br>
<br>
_______________________________________________<br>
Haskell-Cafe mailing list<br>
<a href="mailto:Haskell-Cafe@haskell.org">Haskell-Cafe@haskell.org</a><br>
<a href="http://www.haskell.org/mailman/listinfo/haskell-cafe" target="_blank">http://www.haskell.org/mailman/listinfo/haskell-cafe</a><br>
</font></span></blockquote></div><br></div>