https://gcc.gnu.org/bugzilla/show_bug.cgi?id=92741

--- Comment #4 from rsandifo at gcc dot gnu.org <rsandifo at gcc dot gnu.org> 
---
This comes from:

      if (!useless_type_conversion_p (TREE_TYPE (rhs), TREE_TYPE (v->value)))
        {
          if (fold_convertible_p (TREE_TYPE (rhs), v->value))
            val = fold_build1 (NOP_EXPR, TREE_TYPE (rhs), v->value);
          else if (TYPE_SIZE (TREE_TYPE (rhs))
                   == TYPE_SIZE (TREE_TYPE (v->value)))
            val = fold_build1 (VIEW_CONVERT_EXPR, TREE_TYPE (rhs), v->value);

in ipcp_modif_dom_walker::before_dom_children.  fold_convertible_p
is returning true for the mismatched vector types, which is clearly
a bug and I have a fix.  But does anyone have any thoughts on whether
the above code is correct?  It seems strange to be trusting
fold_convertible_p with the choice when this kind of type punning
always acts as a VIEW_CONVERT_EXPR-style reinterpret of the
memory contents.  Earlier we have:

      if (!v
          || v->by_ref != by_ref
          || maybe_ne (tree_to_poly_int64 (TYPE_SIZE (TREE_TYPE (v->value))),
                       size))
        continue;

which I guess makes it safe in practice.

Reply via email to