comp.lang.ada
 help / color / mirror / Atom feed
From: Gautier write-only <gautier_niouzes@hotmail.com>
Subject: Re: Subtypes boundaries
Date: Mon, 14 Jun 2010 14:01:17 -0700 (PDT)
Date: 2010-06-14T14:01:17-07:00	[thread overview]
Message-ID: <2b13f46b-65f9-450a-bb66-68c6093791c4@s9g2000yqd.googlegroups.com> (raw)
In-Reply-To: 87nijlFa1kU2@mid.individual.net

> type ASTERIX is range -5_000..+10_000;
> subtype IDEFIX is ASTERIX range 1..20_000;

If it is what is in your text book, then it is a mistake - at least
from a didactic perspective...
To my surprise, it looks legal Ada.
One (old) compiler compiles without a complaint;
another one (recent) compiles but issues this warning:

obelix.adb:3:38: warning: static value out of range of type "ASTERIX"
defined at line 2
obelix.adb:3:38: warning: "Constraint_Error" will be raised at run
time

And keeps its promise at run-time:

Execution terminated by unhandled exception
Exception name: CONSTRAINT_ERROR
Message: obelix.adb:3 range check failed

G.



  reply	other threads:[~2010-06-14 21:01 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2010-06-14 20:25 Subtypes boundaries Nobody
2010-06-14 20:36 ` Jeffrey R. Carter
2010-06-17 18:54   ` Nobody
2010-06-17 18:58     ` Nasser M. Abbasi
2010-06-17 19:17     ` Jeffrey R. Carter
2010-06-17 19:53     ` Ludovic Brenta
2010-06-14 20:43 ` Nobody
2010-06-14 21:01   ` Gautier write-only [this message]
2010-06-14 23:31     ` Yannick Duchêne (Hibou57)
2010-06-15  0:01       ` Peter C. Chapin
2010-06-15  0:58         ` Adam Beneschan
2010-06-15  1:05       ` Nobody
2010-06-15  1:20         ` Adam Beneschan
replies disabled

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