]> gitweb.michael.orlitzky.com - hath.git/commitdiff
src/IPv4Address.hs: convert Int to Word32 before doing math in toEnum.
authorMichael Orlitzky <michael@orlitzky.com>
Sun, 3 Mar 2019 15:43:39 +0000 (10:43 -0500)
committerMichael Orlitzky <michael@orlitzky.com>
Sun, 3 Mar 2019 15:43:39 +0000 (10:43 -0500)
On x86, the machine Int type isn't big enough to hold half of the
IPv4 address space. Big addresses get converted into negative numbers,
and all hell breaks loose. Unfortunately, the Int type is baked into
the Enum typeclass, so we can't avoid it entirely. We can however
cast to Word32 before doing any math.

This commit updates the toEnum implementation for IPv4Address to
convert back and forth between Word32, fixing part of this bug.
However, the inverse property of toEnum and fromEnum is still
failing for IPv4Address.

Thanks to Thomas Deutschmann <whissi@gentoo.org> for finding the bug.


No differences found