Skip Menu |

This queue is for tickets about the Math-Int64 CPAN distribution.

Report information
The Basics
Id: 104408
Status: resolved
Priority: 0/
Queue: Math-Int64

People
Owner: Nobody in particular
Requestors: dwheeler [...] cpan.org
Cc:
AdminCc:

Bug Information
Severity: (no value)
Broken in: (no value)
Fixed in: (no value)



Subject: native_if_available disables die_on_overflow
This works as expected: perl -E 'use Math::Int64 qw(int64 :die_on_overflow); say int64 "9223372036854775808"' Math::Int64 overflow: Number is out of bounds for int64_t conversion at -e line 1. But this doesn't: perl -E 'use Math::Int64 qw(int64 :die_on_overflow :native_if_available); say int64 "9223372036854775808"' -9223372036854775808 IMO, overflow errors should still be triggered even when a native return value is wanted. Is there perhaps a workaround where, if I get an object back from int64() I can call a method to get the native Perl scalar value?
On 2015-05-13 13:52:36, DWHEELER wrote: Show quoted text
> Is there perhaps a workaround where, if I get an object back from > int64() I can call a method to get the native Perl scalar value?
To answer my own question, int64_to_number() gives me what I need: perl -E 'use Math::Int64 qw(int64 :die_on_overflow int64_to_number); say int64_to_number int64 "9223372036854775808"' Math::Int64 overflow: Number is out of bounds for int64_t conversion at -e line 1.
Yes, that's the way is should be done. In any case, I have uploaded a new version of the module that warns when both 'die_on_overflow' and 'native_if_available' are enabled.
On 2015-05-14 06:06:32, SALVA wrote: Show quoted text
> Yes, that's the way is should be done. > > In any case, I have uploaded a new version of the module that warns > when both 'die_on_overflow' and 'native_if_available' are enabled.
You really don't want to allow both? Why not? if not, some documentation on this would be welcome. Thanks, David
Subject: Re: [rt.cpan.org #104408] native_if_available disables die_on_overflow
Date: Thu, 14 May 2015 16:37:59 +0000 (UTC)
To: "bug-Math-Int64 [...] rt.cpan.org" <bug-Math-Int64 [...] rt.cpan.org>
From: Salvador Fandino <sfandino [...] yahoo.com>
Show quoted text
----- Original Message -----
> From: David Wheeler via RT <bug-Math-Int64@rt.cpan.org> > To: > Cc: > Sent: Thursday, May 14, 2015 6:01 PM > Subject: [rt.cpan.org #104408] native_if_available disables die_on_overflow > > Queue: Math-Int64 > Ticket <URL: https://rt.cpan.org/Ticket/Display.html?id=104408 > > > On 2015-05-14 06:06:32, SALVA wrote: >
>> Yes, that's the way is should be done. >> >> In any case, I have uploaded a new version of the module that warns >> when both 'die_on_overflow' and 'native_if_available' are
> enabled. > > You really don't want to allow both? Why not?
Because it doesn't work. When native_if_available is set, the module just returns regular perl scalars that are handled by Perl directly, not by the module, and Perl doesn't support checking for overflows.
> if not, some documentation on this would be welcome.
Yes, probably a note on the documentation is needed.
Subject: Re: [rt.cpan.org #104408] native_if_available disables die_on_overflow
Date: Thu, 14 May 2015 10:12:42 -0700
To: bug-Math-Int64 [...] rt.cpan.org
From: "David E. Wheeler" <dwheeler [...] cpan.org>
On May 14, 2015, at 9:38 AM, Salvador Fandiño via RT <bug-Math-Int64@rt.cpan.org> wrote: Show quoted text
> Because it doesn't work. When native_if_available is set, the module just returns regular perl scalars that are handled by Perl directly, not by the module, and Perl doesn't support checking for overflows.
It would work if you did the overflow test first. If it doesn’t overflow, then return the native scalar if possible. D
Subject: Re: [rt.cpan.org #104408] native_if_available disables die_on_overflow
Date: Thu, 14 May 2015 18:14:50 +0000 (UTC)
To: "bug-Math-Int64 [...] rt.cpan.org" <bug-Math-Int64 [...] rt.cpan.org>
From: Salvador Fandino <sfandino [...] yahoo.com>
Show quoted text
----- Original Message -----
> From: David Wheeler via RT <bug-Math-Int64@rt.cpan.org> > To: > Cc: > Sent: Thursday, May 14, 2015 7:13 PM > Subject: Re: [rt.cpan.org #104408] native_if_available disables die_on_overflow > > Queue: Math-Int64 > Ticket <URL: https://rt.cpan.org/Ticket/Display.html?id=104408 > > > On May 14, 2015, at 9:38 AM, Salvador Fandiño via RT > <bug-Math-Int64@rt.cpan.org> wrote: >
>> Because it doesn't work. When native_if_available is set, the module
> just returns regular perl scalars that are handled by Perl directly, not by the > module, and Perl doesn't support checking for overflows. > > It would work if you did the overflow test first. If it doesn’t overflow, then
> return the native scalar if possible.
That only works for the string-to-number conversion functions which are just a small subset of all the ones available.