C++ PATCH to fix ICE with vector expr folding (PR c++/83659)

Nathan Sidwell nathan@acm.org
Wed Jan 3 16:46:00 GMT 2018


On 01/03/2018 11:31 AM, Marek Polacek wrote:
> Here we are crashing because cxx_fold_indirect_ref got a POINTER_PLUS_EXPR
> with offset > signed HOST_WIDE_INT and we tried to convert it to sHWI.
> 
> The matching code in fold_indirect_ref_1 uses uHWIs so I've followed suit.
> But that code now also uses poly_uint64 and I'm not sure if any of the
> constexpr.c code should use it, too.  But this patch fixes the ICE.

This doesn't look right to me, but it doesn't help that the test case 
invokes UB.

> +typedef int V __attribute__ ((__vector_size__ (16)));
> +V a;
> +
> +int
> +main ()
> +{
> +  reinterpret_cast <int *> (&a)[-1] += 1;
> +}

one could make this code well formed with (I think)

typedef int V __attribute__ ((__vector_size__ (16)));
V a[2];

int main ()
{
    return reinterpret_cast <int *> (&a[1])[-1];
}

That should access the final element of the a[0] vector.


nathan
-- 
Nathan Sidwell



More information about the Gcc-patches mailing list