comp.lang.ada
 help / color / mirror / Atom feed
* Unconstrained base subtype questions
@ 2011-03-31 20:25 Alex Mentis
  2011-03-31 21:09 ` Ludovic Brenta
                   ` (3 more replies)
  0 siblings, 4 replies; 10+ messages in thread
From: Alex Mentis @ 2011-03-31 20:25 UTC (permalink / 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



^ permalink raw reply	[flat|nested] 10+ messages in thread

end of thread, other threads:[~2011-04-01  8:20 UTC | newest]

Thread overview: 10+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2011-03-31 20:25 Unconstrained base subtype questions Alex Mentis
2011-03-31 21:09 ` 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

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