https://gcc.gnu.org/bugzilla/show_bug.cgi?id=99122
--- Comment #3 from Martin Jambor <jamborm at gcc dot gnu.org> --- Looking at how expr.c deals with WITH_SIZE_EXPR, perhaps we should do something like the following: diff --git a/gcc/tree-inline.c b/gcc/tree-inline.c index a710fa59027..cdabeb6bafd 100644 --- a/gcc/tree-inline.c +++ b/gcc/tree-inline.c @@ -3418,6 +3418,9 @@ force_value_to_type (tree type, tree value) Still if we end up with truly mismatched types here, fall back to using a VIEW_CONVERT_EXPR or a literal zero to not leak invalid GIMPLE to the following passes. */ + if (TREE_CODE (value) == WITH_SIZE_EXPR) + value = TREE_OPERAND (value, 0); + if (!is_gimple_reg_type (TREE_TYPE (value)) || TYPE_SIZE (type) == TYPE_SIZE (TREE_TYPE (value))) return fold_build1 (VIEW_CONVERT_EXPR, type, value);