On 05/18/2018 12:15 PM, Martin Sebor wrote:
> Under some apparently rare conditions a DECL can have a non-
> constant size that the fix for bug 85753 committed last week
> into trunk was not prepared for.  The attached change removes
> the assumption to avoid the ICE that otherwise results.
> 
> Martin
> 
> PS The test case that triggers the ICE makes use of variable-
> length structs and local functions, both of which are fairly
> obscure GCC extensions that I tend to forget to consider when
> writing GCC code.  I tried to construct a less convoluted (and
> strictly conforming) test case but in all of those I've come
> up with a variable-length object is represented by a pointer
> (pointing to memory returned by __builtin_alloca_with_align()).
> Is there a straightforward way to create a variable-size DECL
> that doesn't rely on GCC extensions?
I think creating a type of a variable size, then an object of that type
is the key.  So a type with a flexible array/vla.  Which is precisely
what your test does.

For the most part DECL_SIZE comes from TYPE_SIZE.  See layout_decl.


> 
> gcc-85826.diff
> 
> 
> PR tree-optimization/85826 - ICE in gimple-ssa-warn-restruct on a 
> variable-length struct
> 
> gcc/ChangeLog:
> 
>       PR tree-optimization/85826
>       * gimple-ssa-warn-restrict.c (builtin_memref::builtin_memref): Avoid
>       assuming that a DECL necesarily has a constant size.
> 
> gcc/testsuite/ChangeLog:
> 
>       PR tree-optimization/85826
>       * gcc.dg/Wrestrict-17.c: New test.
OK.
jeff

Reply via email to