demos/perl ~0 versus ULONG_MAX

Sisyphus kalinabears at
Tue Dec 23 13:36:29 CET 2003

Kevin Ryde wrote:
> In the demos/perl module, scan0 and scan1 have been described as
> returning ULONG_MAX which can be obtained in perl as "~0".
> Unfortunately in perl 5.005 on alpha, this is not true, ULONG_MAX is
> 64-bits but ~0 is 32-bits.
> The choice is between changing the code to be ~0 and describing just
> that.  Or leaving the code and changing the docs to ask people to use
> POSIX:ULONG_MAX() for testing the return.
> Do we have any demos/perl users lurking here?  I'm guessing everybody
> would have written "~0" rather than breaking out the POSIX module and
> calling the ULONG_MAX function.  Unless they already struck this
> problem and realized ULONG_MAX was what they needed.
> I'm feeling inclined to give ~0, since its easier to write.
> This is only a problem for old perl.  5.6 and up seems to have 64-bits
> for ~0 (ie. all IVs), so if most people keep fairly up to date then
> the issue might never arise, but good not to leave it inconsistent.

I don't see that you're under any obligation to document perl bugs 
pertaining to old (no longer maintained) perl code.

Perhaps in the test script (that gets run when you build the module) you 
could put:

if($] < 5.006 && $^O =~ /alpha/i) {
   # print some warning re ~0 and scan0/1

Mind you - I'm not sure that's the exact code you want to use to 
determine whether there's a problem with the OS/perl-version mix - but 
you get the picture :-)


Any emails containing attachments will be deleted from my ISP's mail 
server before I even get to see them. If you wish to email me an 
attachment, please provide advance warning so that I can make the 
necessary arrangements.

More information about the gmp-discuss mailing list