This is the mail archive of the
gcc@gcc.gnu.org
mailing list for the GCC project.
Re: Ada subtypes and base types
Hello,
> > > Jeffrey A Law wrote:
> > > > Another possibility is to simply not allow conversions between a
> > > > subtype and basetype.
> > >
> > > Such a patch also solves the problem. But I'm not sure to understand
> > > the impact on other codes. Is this kind of conversion between a type
> > > and its basetype specific to Ada?
> >
> > this still seems unnecessarily conservative to me. I would just check
> > for types whose TYPE_MIN and TYPE_MAX do not match the natural values
> > derived from the type precision (i.e., those returned by
> > upper_bound_in_type (type, type) and lower_bound_in_type (type, type)).
> I doubt it matters in any significant way -- your proposed solution
> may allow optimization in a few more cases of Ada code, but at a
> compile-time cost (probably not significant).
just forbidding cast to a subtype does not seem enough -- cast from any
type to the type in that TYPE_MIN and MAX do not match TYPE_PRECISION
may cause problems. I am not sure whether such casts really appear,
but I do not see any principial reason why they should not.
Zdenek