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=-0.8 required=5.0 tests=BAYES_00,INVALID_DATE autolearn=no autolearn_force=no version=3.4.4 X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 103376,e258612d447226e4 X-Google-Attributes: gid103376,public X-Google-ArrivalTime: 1994-11-18 13:13:11 PST Path: nntp.gmd.de!xlink.net!howland.reston.ans.net!news.moneng.mei.com!uwm.edu!news.alpha.net!news.mathworks.com!news.duke.edu!eff!blanket.mitre.org!linus.mitre.org!linus!mbunix!eachus From: eachus@spectre.mitre.org (Robert I. Eachus) Newsgroups: comp.lang.ada Subject: Re: Range Check Query Date: 18 Nov 94 12:11:26 Organization: The Mitre Corp., Bedford, MA. Message-ID: References: <9411181527.AA08827@eurocontrol.de> NNTP-Posting-Host: spectre.mitre.org In-reply-to: Bob Wells #402's message of Fri, 18 Nov 1994 16:27:49 +0100 Date: 1994-11-18T12:11:26+00:00 List-Id: In article <9411181527.AA08827@eurocontrol.de> Bob Wells #402 writes: > Why does the following not raise a Constraint_Error exception? > (It doesn't even raise a compile time warning) You really have two different questions. First if M_T(1).Dnspare = 2 then Why doesn't the compiler complain about this? Why should it? The expression on the left is of TYPE Integer, and 2 is certainly convertable to a value of TYPE Integer, and is in the range of Integer. The compiler is allowed to be smart and optimize this to False. (If it is that smart it should probably warn you of the fact that it does so. But I suspect it is smart enough to notice that there are no guarentees on the value of Dnspare...) Second: > The incoming stream definitely has value of 2 occaisionaly in this > component yet it doesn't raise Constraint_Error? Your program is literally erroneous. If the compiler was smart enough to figure this out the "right" exception is PROGRAM_ERROR, but anything the compiler does at this point is legal. You have created an illegal value in M_T(1), then read it, and you expect the compiler to do something other than throw up its hands at this point? The ARG has been back and forth about this and other similar cases. The "best" thing to do in this case is to define a record type in the read procedure which covers all possible values, and do explicit range checking on that. (The value returned can be converted to the type with meaningful ranges.) -- Robert I. Eachus with Standard_Disclaimer; use Standard_Disclaimer; function Message (Text: in Clever_Ideas) return Better_Ideas is...