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] <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.
This commit is contained in:
Willy Tarreau 2019-06-16 18:40:33 +02:00
parent 8daa920ae4
commit 33ccf1cce0
1 changed files with 4 additions and 4 deletions

View 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;
}