]> git.ipfire.org Git - thirdparty/haproxy.git/commitdiff
BUILD: pattern: work around an internal compiler bug in gcc-3.4
authorWilly Tarreau <w@1wt.eu>
Sun, 16 Jun 2019 16:40:33 +0000 (18:40 +0200)
committerWilly Tarreau <w@1wt.eu>
Sun, 16 Jun 2019 16:40:33 +0000 (18:40 +0200)
gcc-3.4 fails to compile pattern.c :

src/pattern.c: In function `pat_match_ip':
src/pattern.c:1092: error: unrecognizable insn:
(insn 186 185 187 9 src/pattern.c:970 (set (reg/f:SI 179)
        (high:SI (const:SI (plus:SI (symbol_ref:SI ("static_pattern") [flags 0x22] <var_decl fe5bae80 static_pattern>)
                    (const_int 8 [0x8]))))) -1 (nil)
    (nil))
src/pattern.c:1092: internal compiler error: in extract_insn, at recog.c:2083

This happens when performing the memcpy() on the union, and in this
case the workaround is trivial (and even cleaner) using a cast instead.

src/pattern.c

index c93be9b59947865856fb755ee98077b9b775aa03..6bf0c945ce0cdd60010756e2333bed733d7d4284 100644 (file)
@@ -967,7 +967,7 @@ struct pattern *pat_match_ip(struct sample *smp, struct pattern_expr *expr, int
                                static_pattern.ref = elt->ref;
                                static_pattern.sflags = PAT_SF_TREE;
                                static_pattern.type = SMP_T_IPV4;
-                               memcpy(&static_pattern.val.ipv4.addr.s_addr, elt->node.key, 4);
+                               static_pattern.val.ipv4.addr = *(struct in_addr *)elt->node.key;
                                if (!cidr2dotted(elt->node.node.pfx, &static_pattern.val.ipv4.mask))
                                        return NULL;
                        }
@@ -989,7 +989,7 @@ struct pattern *pat_match_ip(struct sample *smp, struct pattern_expr *expr, int
                                static_pattern.ref = elt->ref;
                                static_pattern.sflags = PAT_SF_TREE;
                                static_pattern.type = SMP_T_IPV6;
-                               memcpy(&static_pattern.val.ipv6.addr, elt->node.key, 16);
+                               static_pattern.val.ipv6.addr = *(struct in6_addr *)elt->node.key;
                                static_pattern.val.ipv6.mask = elt->node.node.pfx;
                        }
                        return &static_pattern;
@@ -1009,7 +1009,7 @@ struct pattern *pat_match_ip(struct sample *smp, struct pattern_expr *expr, int
                                static_pattern.ref = elt->ref;
                                static_pattern.sflags = PAT_SF_TREE;
                                static_pattern.type = SMP_T_IPV6;
-                               memcpy(&static_pattern.val.ipv6.addr, elt->node.key, 16);
+                               static_pattern.val.ipv6.addr = *(struct in6_addr *)elt->node.key;
                                static_pattern.val.ipv6.mask = elt->node.node.pfx;
                        }
                        return &static_pattern;
@@ -1043,7 +1043,7 @@ struct pattern *pat_match_ip(struct sample *smp, struct pattern_expr *expr, int
                                        static_pattern.ref = elt->ref;
                                        static_pattern.sflags = PAT_SF_TREE;
                                        static_pattern.type = SMP_T_IPV4;
-                                       memcpy(&static_pattern.val.ipv4.addr.s_addr, elt->node.key, 4);
+                                       static_pattern.val.ipv4.addr = *(struct in_addr *)elt->node.key;
                                        if (!cidr2dotted(elt->node.node.pfx, &static_pattern.val.ipv4.mask))
                                                return NULL;
                                }