warn when both die_on_overflow and native_if_available are enabled
Salvador Fandino
9 years ago
0 | 0 |
Revision history for Perl extension Math::Int64.
|
1 | 1 |
|
2 | 2 |
{{$NEXT}}
|
|
3 |
- warn when both native_if_available and die_on_overflow are
|
|
4 |
enabled (bug report by David Wheeler).
|
3 | 5 |
|
4 | 6 |
0.52 2015-03-12
|
5 | 7 |
- include stdint.h when compiling with recent MS compilers
|
2 | 2 |
use strict;
|
3 | 3 |
use warnings;
|
4 | 4 |
|
|
5 |
use Math::Int64 ();
|
|
6 |
|
5 | 7 |
sub import {
|
6 | 8 |
require Math::Int64;
|
7 | 9 |
Math::Int64::_set_may_die_on_overflow(1);
|
8 | |
$^H{'Math::Int64::die_on_overflow'} = 1
|
|
10 |
$^H{'Math::Int64::die_on_overflow'} = 1;
|
|
11 |
goto &Math::Int64::_check_pragma_compatibility;
|
9 | 12 |
}
|
10 | 13 |
|
11 | 14 |
|
2 | 2 |
use strict;
|
3 | 3 |
use warnings;
|
4 | 4 |
|
|
5 |
use Math::Int64 ();
|
|
6 |
|
5 | 7 |
sub import {
|
6 | 8 |
if (Math::Int64::_backend() eq 'IV' and $] >= 5.008) {
|
7 | 9 |
Math::Int64::_set_may_use_native(1);
|
8 | 10 |
$^H{'Math::Int64::native_if_available'} = 1;
|
|
11 |
goto &Math::Int64::_check_pragma_compatibility;
|
9 | 12 |
}
|
10 | 13 |
}
|
11 | 14 |
|
7 | 7 |
require XSLoader;
|
8 | 8 |
XSLoader::load('Math::Int64', $VERSION);
|
9 | 9 |
}
|
|
10 |
|
|
11 |
use warnings::register;
|
10 | 12 |
|
11 | 13 |
use constant MAX_INT64 => string_to_int64 ( '0x7fff_ffff_ffff_ffff');
|
12 | 14 |
use constant MIN_INT64 => string_to_int64 ('-0x8000_0000_0000_0000');
|
|
61 | 63 |
}
|
62 | 64 |
|
63 | 65 |
Math::Int64->export_to_level(1, $pkg, @subs);
|
|
66 |
}
|
|
67 |
|
|
68 |
sub _check_pragma_compatibility {
|
|
69 |
if ($^H{'Math::Int64::native_if_available'} and
|
|
70 |
$^H{'Math::Int64::die_on_overflow'} and
|
|
71 |
warnings::enabled()) {
|
|
72 |
warnings::warn("Math::Int64::die_on_overflow pragma is useless when Math::Int64::native_if_available is also active");
|
|
73 |
}
|
|
74 |
1;
|
64 | 75 |
}
|
65 | 76 |
|
66 | 77 |
use overload ( '+' => \&_add,
|