This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
Re: prevent creation of invalid static constructors from gimplifier
Ian Lance Taylor wrote:
> I was thinking more of checking it in the CONSTRUCTOR case in
> categorize_ctor_elements_1. We want categorize_ctor_elements and
> initializer_constant_valid_p to consistently return the same value.
> Your change assumes that initializer_constant_valid_p will return true
> for any TREE_CONSTANT initializer, but that is not the case.
Indeed. I misinterpreted your former comment
<< And, of course, if we do add that new return value, we might as
well remove the p_nc_elts return value, since it will no longer be
used.
>>
as to be applied to both categorize and categorize_1. I didn't know
how to match this with your other comment about only checking in the
CONSTRUCTOR case in categorize_1 and made incorrect assumptions from
there.
[...]
Thanks for the example.
I think I see what you meant now. Something like the change you suggested
to categorize_1 for the CONSTRUCTOR case only, plus categorize changed into
HOST_WIDE_INT nc_elts = 0;
...
categorize_ctor_elements_1 (ctor, p_nz_elts, &nc_elts, p_elt_count,
p_must_clear);
...
return nc_elts == 0 && TREE_CONSTANT (ctor);
Is this better/correct understanding ?