zero sized initializers with side effects discarded

Daniel Berlin dberlin@dberlin.org
Fri Sep 9 13:11:00 GMT 2005



On Fri, 9 Sep 2005, Olivier Hainque wrote:

> Hello,
>
> In a number of places, the gimplifier simply discards what involves
> zero sized entities. For instance:
>
>  in "gimplify_init_ctor_eval"...
>
>      FOR_EACH_CONSTRUCTOR_ELT (elts, ix, purpose, value)
>      ...
>      if (zero_sized_field_decl (purpose))
>        continue;
>
>   or in "gimplify_modify_expr"...
>
>      /* For zero sized types only gimplify the left hand side and
>         right hand side as statements and throw away the assignment.  */
>      if (zero_sized_type (TREE_TYPE (*from_p)))
>          ...
>
> This is causing troubles when side effects are so discarded, for instance
> a call to a function returning a zero sized type.

Even if you "fixed" init_ctor_eval (modify_expr gimplifies the lhs and rhs 
and throws away the assignment), you're going to run into problems in 
the subvar machinery if you really have 0 sized field accesses with side 
effects.

I'm not sure what the heck a "0 sized field access with side effects" 
does.

After all, a 0 sized field has no space, etc (in fact, it is nothing), so 
how could you side-effect by accessing one, since any such access must do 
nothing?



More information about the Gcc mailing list