From: Willy Tarreau Date: Sun, 16 Jun 2019 16:40:33 +0000 (+0200) Subject: BUILD: pattern: work around an internal compiler bug in gcc-3.4 X-Git-Tag: v2.0.0~4 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=33ccf1cce04069f27ebb868f5617672ed4e21cf4;p=thirdparty%2Fhaproxy.git BUILD: pattern: work around an internal compiler bug in gcc-3.4 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] ) (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. --- diff --git a/src/pattern.c b/src/pattern.c index c93be9b599..6bf0c945ce 100644 --- a/src/pattern.c +++ b/src/pattern.c @@ -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; }