> The patch does add a boolean "expand_reference" parameter to > expand_expr_real and expand_expr_real_1. I pass true when I intend to use > the returned memory context as an array reference, instead of a value. At > places where mis-aligned values are extracted, I do not return a register > with the extracted mis-aligned value if expand_reference is true. When I > have a VIEW_CONVERT_EXPR I pay attention to pass down the outer > "expand_reference" to the inner expand_expr_real call. Expand_reference, is > pretty much similar to the expand_modifier "EXPAND_MEMORY".
IMO that's not acceptable as-is, you're papering over the real issue which are the out-of-bounds accesses in the code, i.e. you essentially have an object with variable size and non-BLKmode. The patch is too big an hammer for such an obvious lie to the middle-end. Moreover there is not a _single_ line of explanation in it. If we really want to go for a hack instead of fixing the underlying issue, it should be restricted to the cases where stor-layout.c goes wrong. -- Eric Botcazou