From mboxrd@z Thu Jan 1 00:00:00 1970 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on polar.synack.me X-Spam-Level: X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00 autolearn=ham autolearn_force=no version=3.4.4 X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 103376,4fb6ec6cd054de65 X-Google-Attributes: gid103376,public X-Google-ArrivalTime: 2002-03-11 09:16:13 PST Newsgroups: comp.lang.ada Path: archiver1.google.com!news1.google.com!newsfeed.stanford.edu!news-spur1.maxwell.syr.edu!news.maxwell.syr.edu!nntp.abs.net!uunet!dca.uu.net!ash.uu.net!xyzzy!nntp From: Jeffrey Carter Subject: Re: constrained subtypes X-Nntp-Posting-Host: e246420.msc.az.boeing.com Content-Type: text/plain; charset=us-ascii Message-ID: <3C8CE060.5E003C0@boeing.com> Sender: nntp@news.boeing.com (Boeing NNTP News Access) Content-Transfer-Encoding: 7bit Organization: The Boeing Company X-Accept-Language: en References: <3c8cc63b$1@pull.gecm.com> Mime-Version: 1.0 Date: Mon, 11 Mar 2002 16:50:40 GMT X-Mailer: Mozilla 4.73 [en]C-CCK-MCD Boeing Kit (WinNT; U) Xref: archiver1.google.com comp.lang.ada:21066 Date: 2002-03-11T16:50:40+00:00 List-Id: George Stevens wrote: > > We're trying to use subtypes of base integer, constraining them 1 .. 8 > (i.e. static values) > When we use these types in a case statement, covering values 1 - 8, the > Aonix Ada compiler (7.1.2) complains that we haven't defined "others". > However, we shouldn't need to, as all cases are within the constrained > limits. I've looked at Programming in Ada 95 - Barnes (p106) which seems to > suggest that we're doing the right thing language-wise, so long as the range > limits are static types. > > Is this a compiler funny or an Ada funny? Without seeing your code, I can't say. The ARM says The possible values of the expression shall be covered as follows: * If the expression is a name (including a type_conversion or a function_call) having a static and constrained nominal subtype, or is a qualified_expression whose subtype_mark denotes a static and constrained scalar subtype, then each non-others discrete_choice shall cover only values in that subtype, and each value of that subtype shall be covered by some discrete_choice (either explicitly or by others). * If the type of the expression is root_integer, universal_integer, or a descendant of a formal scalar type, then the case_statement shall have an others discrete_choice. * Otherwise, each value of the base range of the type of the expression shall be covered (either explicitly or by others). If your case expression falls under the first bullet, then it's a compiler bug. If it falls under the other 2 bullets, though, it is an error in your understanding. >From the compiler message information you've provided, it sounds as if the compiler thinks your expression falls under the second bullet (others choice required). -- Jeffrey Carter