[PATCH] Fix PR22371, enable type-checking for all stages

Richard Guenther richard.guenther@gmail.com
Wed Mar 26 20:23:00 GMT 2008


On Wed, Mar 26, 2008 at 8:49 PM, Michael Matz <matz@suse.de> wrote:
> Hi,
>
>
>  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
>  slot.
>
>  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
>  okay.

Uh well, this integer subtype indeed looks strange.  So this is where the
bug probably lies (though get_unwidened shouldn't rewrite types to
strip Ada sub-types as we are supposed to preserve them - otherwise
useless_type_conversion_p could care less there as well).

Richard.



More information about the Gcc-patches mailing list