This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
Make srand treat "-1" as -1
[perl5.git] / pp.c
diff --git a/pp.c b/pp.c
index f4c5693..c3221d5 100644 (file)
--- a/pp.c
+++ b/pp.c
@@ -3259,7 +3259,8 @@ PP(pp_chr)
     SvGETMAGIC(TOPs);
     if (((SvIOKp(TOPs) && !SvIsUV(TOPs) && SvIV_nomg(TOPs) < 0)
         ||
-        (SvNOKp(TOPs) && SvNV_nomg(TOPs) < 0.0))) {
+        ((SvNOKp(TOPs) || (SvOK(TOPs) && !SvIsUV(TOPs)))
+         && SvNV_nomg(TOPs) < 0.0))) {
        if (IN_BYTES) {
            value = SvUV_nomg(TOPs); /* chr(-1) eq chr(0xff), etc. */
            (void)POPs;