comp.lang.ada
 help / color / mirror / Atom feed
From: aschwarz@acm.org (skidmarks)
Subject: String Pointer Bug
Date: 2 Nov 2004 11:32:47 -0800
Date: 2004-11-02T11:32:47-08:00	[thread overview]
Message-ID: <35f054ea.0411021132.6b03488@posting.google.com> (raw)

(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;



             reply	other threads:[~2004-11-02 19:32 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2004-11-02 19:32 skidmarks [this message]
2004-11-04  6:18 ` String Pointer Bug Per Sandberg
  -- strict thread matches above, loose matches on Subject: below --
2004-11-08 13:34 Christoph Karl Walter Grein
2004-11-09 16:47 ` skidmarks
2004-11-09 19:35   ` Martin Krischik
replies disabled

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox