develooper Front page | perl.perl5.porters | Postings from January 2001

Re: [PATCH: perl@8429] lib/tie-substrhash.t FAILED at test 11

Thread Previous
From:
Jarkko Hietaniemi
Date:
January 17, 2001 06:40
Subject:
Re: [PATCH: perl@8429] lib/tie-substrhash.t FAILED at test 11
Message ID:
20010117084010.H21462@chaos.wustl.edu
On Wed, Jan 17, 2001 at 03:16:43PM +0100, Roca, Ignasi wrote:
> There is a bug in pp_int() function that has a bad influence in the wrap
> method of Tie::Substrhash
> 
> Try following perl-script:
> 
> $t0 = 279964589018079;
> 
> $t1 = int($t0 / 59);
> print "int($t0/59)=$t1\n";
> 
> The result is 
> int(279964589018079/59)=4745162525730.15
>
> As you can see result is not an integer.

Wow, there's definitely a bug in there, though I see it a little
bit differently:

./perl -le 'print int(279964589018079/59)'

Attempt to free unreferenced scalar.

mimosa being a Solaris/sparc box.

(Note that 279964589018079 is large enough to overflow 32 bits,
so in the general case you really shouldn't assume that you get
any accurate results from the division, though.)
 
> Following is a patch to correct the bug
> ===============================================
> --- pp.c.orig   Tue Jan  9 05:14:45 2001
> +++ pp.c        Wed Jan 17 15:10:30 2001
> @@ -2593,6 +2593,7 @@
>                   (void)Perl_modf(tmp, &tmp);
>                   value = (NV)tmp;
>  #endif
> +                 SETn(value);

Thanks, applied.

>               }
>           }
>           else {
> ===============================================
> 
> -- Ignasi Roca

-- 
$jhi++; # http://www.iki.fi/jhi/
        # There is this special biologist word we use for 'stable'.
        # It is 'dead'. -- Jack Cohen

Thread Previous


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