This is the mail archive of the
mailing list for the GCC project.
Re: [PATCH] Fix PR22371, enable type-checking for all stages
On Wed, 26 Mar 2008, Paolo Bonzini wrote:
> > I don't know what would be the best solution here, but the
> > verification code should not call back into the language front-end
> > (via lang_hooks). I know that it currently does anyway (via
> > useless_type_conversion_p_1), but that eventually should go away, so
> > adding more dependencies on the front-end isn't wise.
> I don't think this patch is that ugly.
I used "unwise" :-)
> type_for_size is one of the hooks that in theory could go away sooner
> than later
This is true, but the patch is also suboptimal from another perspective.
What the checking is about is to ensure that the TREE_TYPE of aggregate
expressions doesn't hold any interesting information that couldn't also be
gathered by the type of the operand. This is a nice thing to ensure
because it means that we somewhen would be able to get rid of this extra
A truncation isn't useless, hence the error. Which also means that this
mismatch in outer and inner type has a real effect as far as the
middle-end is concerned, which has to be represented explicitely.
Ignoring it at only this place could still make this type mismatch
propagate into other places resulting in checking errors there.
Now, due to the min/max values, this isn't actually a real effect, though.
I find it ugly that the original subtype has a precision of 32, although
all representable values require only 8 bit, but OTOH its size is four
byte, and a precision of only 8 would also be strange, so I guess it's
But then I think the right place to change would actually be
useless_type_conversion_1, where it checks for type precision. It could
accept unequal precision, iff the min/max values of the wider type fit
into the smaller precision.
get_unwidened could also be changed to either apply an appropriate
conversion or just not do this fiddling with COMPONENT_REFs.