This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: [patch] for PRs 27639 and 26719


On Thu, 6 Jul 2006, Duncan Sands wrote:

> > How do subtypes wrap, if at all?  If you have an unsigned [0, 7], what
> > is the result of u + 8?  What is the result of u + 256 (if the base type
> > was unsigned char)?  Is it defined?
> 
> Hi Richard, in Ada arithmetic on subtypes is defined by: convert to base
> type, perform arithmetic, convert back.  The language requires a check
> that the value is in the range of the subtype, with an exception being
> raised if not (the Ada front-end inserts this check except when it can
> prove that it is not needed).

Sure, I am aware of that.

> (B) u + 256.  Since 256 does not even belong to the type unsigned char,
> this expression cannot occur.

I meant to ask, if the arithmetic in the basetype wraps and the result
is within the subtype is this undefined behavior or required to compute
ok?

Richard.

--
Richard Guenther <rguenther@suse.de>
Novell / SUSE Labs


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]