This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
Perl_sv_vcatpvfn_flags: clarify GCC bug comments
authorDavid Mitchell <davem@iabyn.com>
Fri, 2 Jun 2017 11:23:32 +0000 (12:23 +0100)
committerDavid Mitchell <davem@iabyn.com>
Wed, 7 Jun 2017 08:11:09 +0000 (09:11 +0100)
In particular it wasn't clear what bug was being worked around, nor that
'#13488' referred to a GNU ticket rather than a perl ticket.

This bug was fixed back in 2004, but the workaround is fairly harmless, so
I've left it as-is.

sv.c

diff --git a/sv.c b/sv.c
index 034792d..75447d4 100644 (file)
--- a/sv.c
+++ b/sv.c
@@ -12581,7 +12581,9 @@ Perl_sv_vcatpvfn_flags(pTHX_ SV *const sv, const char *const pat, const STRLEN p
                         }
                     }
                     else {
-                        IV tiv = SvIV_nomg(argsv); /* work around GCC bug #13488 */
+                        /* assign to tiv then cast to iv to work around
+                         * 2003 GCC cast bug (gnu.org bugzilla #13488) */
+                        IV tiv = SvIV_nomg(argsv);
                         switch (intsize) {
                         case 'c':  iv = (char)tiv;   break;
                         case 'h':  iv = (short)tiv;  break;
@@ -12637,7 +12639,9 @@ Perl_sv_vcatpvfn_flags(pTHX_ SV *const sv, const char *const pat, const STRLEN p
                         }
                     }
                     else {
-                        UV tuv = SvUV_nomg(argsv); /* work around GCC bug #13488 */
+                        /* assign to tiv then cast to iv to work around
+                         * 2003 GCC cast bug (gnu.org bugzilla #13488) */
+                        UV tuv = SvUV_nomg(argsv);
                         switch (intsize) {
                         case 'c': uv = (unsigned char)tuv;  break;
                         case 'h': uv = (unsigned short)tuv; break;