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=-2.9 required=5.0 tests=BAYES_00,MAILING_LIST_MULTI autolearn=unavailable autolearn_force=no version=3.4.4 X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 103376,9e499c74312ed3f0 X-Google-Attributes: gid103376,public X-Google-ArrivalTime: 2001-05-17 22:39:20 PST Path: archiver1.sj.google.com!newsfeed.google.com!newsfeed.stanford.edu!news.tele.dk!193.251.151.101!opentransit.net!jussieu.fr!enst!enst.fr!not-for-mail From: Christoph Grein Newsgroups: comp.lang.ada Subject: Re: Static assertions Date: Fri, 18 May 2001 07:34:57 +0200 (MET DST) Organization: ENST, France Sender: comp.lang.ada-admin@ada.eu.org Message-ID: Reply-To: comp.lang.ada@ada.eu.org NNTP-Posting-Host: marvin.enst.fr Mime-Version: 1.0 Content-Type: TEXT/plain; charset=us-ascii X-Trace: avanie.enst.fr 990164359 14458 137.194.161.2 (18 May 2001 05:39:18 GMT) X-Complaints-To: usenet@enst.fr NNTP-Posting-Date: Fri, 18 May 2001 05:39:18 +0000 (UTC) To: comp.lang.ada@ada.eu.org Return-Path: Content-MD5: QrbM3sjfETFa9xu0hMcuRA== X-Mailer: dtmail 1.2.1 CDE Version 1.2.1 SunOS 5.6 sun4u sparc Errors-To: comp.lang.ada-admin@ada.eu.org X-BeenThere: comp.lang.ada@ada.eu.org X-Mailman-Version: 2.0.3 Precedence: bulk X-Reply-To: Christoph Grein List-Help: List-Post: List-Subscribe: , List-Id: comp.lang.ada mail<->news gateway List-Unsubscribe: , List-Archive: Errors-To: comp.lang.ada-admin@ada.eu.org X-BeenThere: comp.lang.ada@ada.eu.org Xref: archiver1.sj.google.com comp.lang.ada:7630 Date: 2001-05-18T07:34:57+02:00 Robert A Duff wrote: > Interesting. But shouldn't it be Assert'(...)? > ^ ie a qualified expression package Verifier is subtype Assert is Boolean range True .. True; Assert_1 : constant := Boolean'Pos (Assert (Integer'Size = 16)); Assert_2 : constant := Boolean'Pos (Assert (Integer'Size = 2 * Character'Size)); end Verifier; With a type conversion this compiles on my Apex Ada 95 Compiler 3.0.0b on Solaris and produces "0 0", with a qualified expression, it gives me the error message: Boolean'Pos (Assert'(Integer'Size = 16)) is disallowed since it is static and will raise Constraint_Error [RM_95 4.9(34)] It seems like the type conversion is ignored. ARM 4.6(28) For the evaluation of a type_conversion that is a value conversion, the operand is evaluated, and then the value of the operand is converted to a corresponding value of the target type, if any. If there is no value of the target type that corresponds to the operand value, Constraint_Error is raised[; this can only happen on conversion to a modular type, and only when the operand value is outside the base range of the modular type.] Additional rules follow: ARM 4.6(34) Enumeration Type Conversion ARM 4.6(35) The result is the value of the target type with the same position number as that of the operand value. Thus there is nowhere specified that the subtype range is checked. Put_Line (Integer'Image (Natural (-2.3))); compiles just fine and produces -2. ARM 4.7(4) The evaluation of a qualified_expression evaluates the operand (and if of a universal type, converts it to the type determined by the subtype_mark) and checks that its value belongs to the subtype denoted by the subtype_mark. The exception Constraint_Error is raised if this check fails. So thanx to Robert Duff for hinting. Christoph Grein