This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
Re: [patch] Fix pr23046
- From: kenner at vlsi1 dot ultra dot nyu dot edu (Richard Kenner)
- To: rth at redhat dot com
- Cc: gcc-patches at gcc dot gnu dot org
- Date: Mon, 19 Sep 05 06:27:14 EDT
- Subject: Re: [patch] Fix pr23046
I'm inclined to think this would be an error already. If type T has
bounds less than the precision, then there should never ever be a
variable of type T with a true value outside those bounds. Which
means you should do all checking *before* you get to type T.
I don't know if that's practical or not though.
It's tricky because of things like the precise semantics of uninitialized
variables and things in Ada like:
v := unchecked_convert (foo);
if v'valid then
I think there always needs to be a way for a front end to generate the explicit
range check. Otherwise, we're in the business of having the middle-end deal
with areas of language semantics that are very subtle.
An alternate is to emit a VIEW_CONVERT_EXPR for the conversion, and
document that VRP should not look through that expression.
It's not clear it can always be a V_C_E because we only really define that
when two types have the same size, but there's no requirement that a subtype
have the same size as its base type, so the conversion between the two needs
to be a regular conversion, not a V_C_E.