summaryrefslogtreecommitdiff
path: root/numeric.c
diff options
context:
space:
mode:
authorDavid Mitchell <davem@iabyn.com>2010-04-15 10:20:50 +0100
committerDavid Mitchell <davem@iabyn.com>2010-04-15 10:32:59 +0100
commitf2338a2e8347fc967ab6b9af21d948258b88e341 (patch)
treeac9b735cf41f4c61d74904471fdbdd84297fdeeb /numeric.c
parentdb63319f533e643ef6aac622fcae9a2f7ceabb0d (diff)
downloadperl-f2338a2e8347fc967ab6b9af21d948258b88e341.tar.gz
use cBOOL for bool casts
bool b = (bool)some_int doesn't necessarily do what you think. In some builds, bool is defined as char, and that cast's behaviour is thus undefined. So this line in mg.c: const bool was_temp = (bool)SvTEMP(sv); was actually setting was_temp to false even when the SVs_TEMP flag was set. Fix this by replacing all the (bool) casts with a new cBOOL() cast macro that (hopefully) does the right thing.
Diffstat (limited to 'numeric.c')
-rw-r--r--numeric.c6
1 files changed, 3 insertions, 3 deletions
diff --git a/numeric.c b/numeric.c
index bfe67427a6..b116376916 100644
--- a/numeric.c
+++ b/numeric.c
@@ -142,7 +142,7 @@ Perl_grok_bin(pTHX_ const char *start, STRLEN *len_p, I32 *flags, NV *result)
NV value_nv = 0;
const UV max_div_2 = UV_MAX / 2;
- const bool allow_underscores = (bool)(*flags & PERL_SCAN_ALLOW_UNDERSCORES);
+ const bool allow_underscores = cBOOL(*flags & PERL_SCAN_ALLOW_UNDERSCORES);
bool overflowed = FALSE;
char bit;
@@ -259,7 +259,7 @@ Perl_grok_hex(pTHX_ const char *start, STRLEN *len_p, I32 *flags, NV *result)
UV value = 0;
NV value_nv = 0;
const UV max_div_16 = UV_MAX / 16;
- const bool allow_underscores = (bool)(*flags & PERL_SCAN_ALLOW_UNDERSCORES);
+ const bool allow_underscores = cBOOL(*flags & PERL_SCAN_ALLOW_UNDERSCORES);
bool overflowed = FALSE;
PERL_ARGS_ASSERT_GROK_HEX;
@@ -373,7 +373,7 @@ Perl_grok_oct(pTHX_ const char *start, STRLEN *len_p, I32 *flags, NV *result)
UV value = 0;
NV value_nv = 0;
const UV max_div_8 = UV_MAX / 8;
- const bool allow_underscores = (bool)(*flags & PERL_SCAN_ALLOW_UNDERSCORES);
+ const bool allow_underscores = cBOOL(*flags & PERL_SCAN_ALLOW_UNDERSCORES);
bool overflowed = FALSE;
PERL_ARGS_ASSERT_GROK_OCT;