On Fri, 18 Dec 2015, Marek Polacek wrote:

> +       tree sz = TYPE_SIZE_UNIT (TREE_TYPE (lhs_type));
> +       rhs = fold_build2_loc (loc, MULT_EXPR, rhs_type, rhs,
> +                              convert (rhs_type, sz));

Converting the size to rhs_type seems wrong, as does multiplying in 
rhs_type.  In a test like

struct s { char a[256]; } *_Atomic p;
char c;
void f (void) { p += c; }

rhs_type is char and the conversion of the size to char will result in 0.  
(Of course this needs expanding to produce an executable test that fails 
with the present patch.)  Instead, both size and rhs should be converted 
to ptrdiff_t and the multiplication done in ptrdiff_t.

-- 
Joseph S. Myers
jos...@codesourcery.com

Reply via email to