comp.lang.ada
 help / color / mirror / Atom feed
From: "Alex Mentis" <foo@invalid.invalid>
Subject: Unconstrained base subtype questions
Date: Thu, 31 Mar 2011 20:25:13 +0000 (UTC)
Date: 2011-03-31T20:25:13+00:00	[thread overview]
Message-ID: <in2nv8$v3e$1@dont-email.me> (raw)

The following does not cause a constraint error in my version of GNAT
on my system:

...

Integer_Result := (Integer'Last + Integer'Last) / 2;

...


If I understand correctly, this is because the Integer operators are
defined for operands of type Integer'Base, which is an unconstrained
subtype and allows the operands to be stored in extended-length
registers so that intermediate values in calculations do not overflow.

My questions are:

1) Do I understand correctly what's going on?

2) Does the language make any guarantees about preventing spurious
overflow, or am I just getting lucky with my compiler/architecture? If
guarantees are made by the language, what are they?

Thanks,
Alex



             reply	other threads:[~2011-03-31 20:25 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-03-31 20:25 Alex Mentis [this message]
2011-03-31 21:09 ` Unconstrained base subtype questions Ludovic Brenta
2011-03-31 21:26   ` Alex Mentis
2011-03-31 21:36     ` Ludovic Brenta
2011-03-31 22:18       ` Adam Beneschan
2011-03-31 21:10 ` Adam Beneschan
2011-03-31 21:18 ` Simon Wright
2011-03-31 21:24 ` Randy Brukardt
2011-03-31 21:51   ` Alex Mentis
2011-04-01  8:20     ` Dmitry A. Kazakov
replies disabled

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox