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.

I have been experimenting with a simple patch adding side effects
checks to the conditions, like "! TREE_SIDE_EFFECTS (value)" in
init_ctor_eval and "! TREE_SIDE_EFFECTS (*from_p)" in modify_expr.

The first programs in which I've observed problems were in Ada, and
the patch helped them.

Manual testing for C was not as successful (expected calls still
missing), due to differences in the way TREE_SIDE_EFFECTS is set on
various trees.

Automated testing (make check) even triggered an ICE on zero-strct-4.c.

Are the TREE_SIDE_EFFECTS checks mentioned above sensible ?

I'd be happy to investigate further, provide testcases, work on extra
patches, etc, and would welcome feedback first to ensure I'm searching
in the right direction :)

Thanks in advance for your advices,

With Kind Regards,

Olivier







Reply via email to