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: 103376,29c1212970bb6877,start X-Google-Attributes: gid103376,public X-Google-Language: ENGLISH,ASCII-7-bit Path: g2news1.google.com!postnews1.google.com!not-for-mail From: aschwarz@acm.org (skidmarks) Newsgroups: comp.lang.ada Subject: String Pointer Bug Date: 2 Nov 2004 11:32:47 -0800 Organization: http://groups.google.com Message-ID: <35f054ea.0411021132.6b03488@posting.google.com> NNTP-Posting-Host: 199.46.200.238 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 8bit X-Trace: posting.google.com 1099423967 1128 127.0.0.1 (2 Nov 2004 19:32:47 GMT) X-Complaints-To: groups-abuse@google.com NNTP-Posting-Date: Tue, 2 Nov 2004 19:32:47 +0000 (UTC) Xref: g2news1.google.com comp.lang.ada:5969 Date: 2004-11-02T11:32:47-08:00 List-Id: (Program below): The same code fragment was run on two different compilers, GNAT and another commercial vendor, 'compiler. The results are inconsistent and I don't believe that both sets of errors can be correct. Before I scream and holler, I wonder if there are wiser heads who can provide insight into which (if any) compiler version is incorrect. The summary is that a pointer to a definite type and a pointer to an indefinite typed value have different constraints, detected and reported. I would assume that compliant compilers would complain similarly. Thanks art ------------------------------ C O D E ------------------------------ procedure Bug is type String_Ptr is access all String; subtype Str_Ptr is String_Ptr( 1 .. 12 ); type String_Array is array( 1 .. 68 ) of aliased String( 1 .. 12 ); Input : String_Array := ( others => (others => ' ') ); StrArray : array( 1 .. 68 ) of aliased String( 1 .. 12 ); Strng : aliased String := "one two three"; -- GNAT warning not issued by Compiler -- >>> warning: aliased object has explicit bounds -- >>> warning: declare without bounds (and with explicit initialization) -- >>> warning: for use with unconstrained access Str : String_Ptr; Str_Def : Str_Ptr; -- Compiler Diagnostic Message -- LRM:3.10.2(27) The nominal subtype of the prefix to 'ACCESS or -- 'UNCHECKED_ACCESS must either statically match -- the expected type or the designated subtype must be -- discriminated and unconstrained -- GNAT (gcc-3.3.1 & gcc-3.3.3) -- object subtype must statically match designated subtype -- Error Messages (See above) begin -- Bug GNAT COMPILER Str := Input(1)'Access; -- X X Str := StrArray(1)'Access; -- X X Str := Strng'Access; Str_Def := Input(1)'Access; -- X Str_Def := StrArray(1)'Access; -- X Str_Def := Strng'Access; -- X end Bug;