develooper Front page | perl.perl5.porters | Postings from July 2018

Re: regen/mph.pl reuse troubles

Thread Previous | Thread Next
From:
demerphq
Date:
July 13, 2018 14:42
Subject:
Re: regen/mph.pl reuse troubles
Message ID:
CANgJU+XFf7VJeq+BF8_LwKw3vek7hchUeoNB362Tv+nPcYotNg@mail.gmail.com
On Thu, 5 Jul 2018, 12:12 bulk 88, <bulk88@hotmail.com> wrote:

>
> 32 bit perl generates different numbers in the mph hash than 64 bit
> perl. I'll guess more "use integer" is needed somewhere in the code.
>

Actually no, more use integer doesn't fix this and causes other issues.

The problem is that while use integer disables conversion to floating
point, which we *want*, it also causes the return from _fnv() to be
*signed* which then causes the minimum perfect hash construction to produce
surprising results. A simple fix on little endian boxen is to change the
return of _fnv() to

return unpack "V", pack "l", $h;

Which in my testing causes the 32bit builds to produce the same output as
the 64bit builds.

I am traveling right now so it's a bit difficult to do more than write this
mail. If no-one beats me to it I will push the patch when I return.

Fwiw, it would be nice to have a "no float_conversion" instead of "use
integer" for situations like this where we want to avoid floating point
conversion but where we do NOT want signed/integer semantics. "use integer"
affects too much and easily results in surprise, such as how it changes
the behaviour of the % (Modulo operator), which for instance causes an
infinite loop in the seed selection logic due to signedness issues.

Sigh.

Yves

Thread Previous | Thread Next


nntp.perl.org: Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at ask@perl.org | Group listing | About