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-Thread: a07f3367d7,a1ec518c53a7048d X-Google-Attributes: gida07f3367d7,public,usenet X-Google-NewGroupId: yes X-Google-Language: ENGLISH,ASCII-7-bit Path: g2news2.google.com!postnews.google.com!k26g2000vbp.googlegroups.com!not-for-mail From: AdaMagica Newsgroups: comp.lang.ada Subject: Re: getting back to null range Date: Sun, 12 Jul 2009 11:20:07 -0700 (PDT) Organization: http://groups.google.com Message-ID: References: NNTP-Posting-Host: 91.13.241.46 Mime-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit X-Trace: posting.google.com 1247422807 27097 127.0.0.1 (12 Jul 2009 18:20:07 GMT) X-Complaints-To: groups-abuse@google.com NNTP-Posting-Date: Sun, 12 Jul 2009 18:20:07 +0000 (UTC) Complaints-To: groups-abuse@google.com Injection-Info: k26g2000vbp.googlegroups.com; posting-host=91.13.241.46; posting-account=rmHyLAoAAADSQmMWJF0a_815Fdd96RDf User-Agent: G2/1.0 X-HTTP-UserAgent: Mozilla/5.0 (Windows; U; Windows NT 5.1; de; rv:1.9.0.11) Gecko/2009060215 Firefox/3.0.11,gzip(gfe),gzip(gfe) Xref: g2news2.google.com comp.lang.ada:7019 Date: 2009-07-12T11:20:07-07:00 List-Id: This is an excerpt (and slightly modified) of what anon proposed as a test program. ---- with Ada.Integer_Text_IO ; with Ada.Text_IO ; use Ada.Integer_Text_IO ; use Ada.Text_IO ; procedure t is -- Display String values, with a title procedure Put ( T : String ; B : String ) is begin Put ( T ) ; Put ( "'( " ) ; Put ( B'First ) ; Put ( " .. " ) ; Put ( B'Last ) ; Put ( " ) => " ) ; Put ( B ) ; Put ( ", Length => " ) ; Put ( B'length ) ; New_Line; end Put ; A : Positive range -5 .. -7 ; -- Value is a nul range -- Creates the compiler warning message begin declare -- Without these pragma statements the following declaration -- statement will compile but generates an C_E at run time -- pragma Suppress ( Index_Check ) ; -- pragma Suppress ( Range_Check ) ; S_B : String := ( A => 'Z' ) ; -- should be equal to S_A begin Put (A); Put (A'Size); New_Line; Put ( "null S_B", S_B ) ; end ; end t ; --- I do not understand what (s)he want's to prove with this piece of code. The declaration of A produces a warning, because it is read but never assigned. His (her) assertion that the value is a null range is wrong. A value is *never* a range. The subtype of A is a null range so that one cannot assign any value to A. But nevertheless A exists and has a size and an address and there is some random sequence of bits at that address which can be interpreted as an integer. My result is: 4201563 32 null S_B'( 4201563 .. 4201563 ) => Z, Length => 1 anon got an exception without pragma Suppress because in his case A had the sequence of bit that interpreted as integer was 0, which is not in range of Positive. So the exception is appropriate. If (s)he suppresses the check, the program is erroneous if the check would have failed. So what does (s)he prove with an erroneous program? In my case, the value is in Positive, so no exception. And of course S_B is not a null string because it is initialized with an aggregate that has a value (albeit a random one). For any integers A, B such that the following is legal X: String := (A..B => something); -- A..B is a range (might be a null range) is not the same as X: String := (A => something); -- an aggregate with one component (if A in Positive)