summaryrefslogtreecommitdiff
path: root/mg.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 /mg.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 'mg.c')
-rw-r--r--mg.c4
1 files changed, 2 insertions, 2 deletions
diff --git a/mg.c b/mg.c
index 3fb8ec43f4..4a8d7673a5 100644
--- a/mg.c
+++ b/mg.c
@@ -193,7 +193,7 @@ Perl_mg_get(pTHX_ SV *sv)
{
dVAR;
const I32 mgs_ix = SSNEW(sizeof(MGS));
- const bool was_temp = (bool)SvTEMP(sv);
+ const bool was_temp = cBOOL(SvTEMP(sv));
bool have_new = 0;
MAGIC *newmg, *head, *cur, *mg;
/* guard against sv having being freed midway by holding a private
@@ -2359,7 +2359,7 @@ Perl_magic_set(pTHX_ SV *sv, MAGIC *mg)
sv_setsv(PL_bodytarget, sv);
break;
case '\003': /* ^C */
- PL_minus_c = (bool)SvIV(sv);
+ PL_minus_c = cBOOL(SvIV(sv));
break;
case '\004': /* ^D */