This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
lib/ExtUtils/typemap: silence g++ warning.
authorDavid Mitchell <davem@iabyn.com>
Tue, 19 Jan 2016 12:23:08 +0000 (12:23 +0000)
committerDavid Mitchell <davem@iabyn.com>
Tue, 19 Jan 2016 12:23:08 +0000 (12:23 +0000)
From the added code comment:

    The weird way this is written is because g++ is dumb
    enough to warn "comparison is always false" on something
    like:

    sizeof(a) > sizeof(b) && a > B_t_MAX

    (where the LH condition is false)

lib/ExtUtils/typemap

index 1cdb846..4bfba95 100644 (file)
@@ -379,9 +379,17 @@ T_ARRAY
         {
            U32 ix_$var;
             SSize_t extend_size =
-                sizeof(size_$var) > sizeof(SSize_t) && size_$var > SSize_t_MAX
-                    ? -1 /* might wrap; -1 triggers a panic in EXTEND() */
-                    : (SSize_t)size_$var;
+                /* The weird way this is written is because g++ is dumb
+                 * enough to warn "comparison is always false" on something
+                 * like:
+                 *
+                 * sizeof(a) > sizeof(b) && a > B_t_MAX
+                 *
+                 * (where the LH condition is false)
+                 */
+                (size_$var > (sizeof(size_$var) > sizeof(SSize_t)
+                              ? SSize_t_MAX : size_$var))
+                ? -1 : (SSize_t)size_$var;
            EXTEND(SP, extend_size);
            for (ix_$var = 0; ix_$var < size_$var; ix_$var++) {
                ST(ix_$var) = sv_newmortal();