TEAM-ADA Archives

Team Ada: Ada Programming Language Advocacy


Options: Use Classic View

Use Monospaced Font
Show Text Part by Default
Show All Mail Headers

Topic: [<< First] [< Prev] [Next >] [Last >>]

Print Reply
"Martin C. Carlisle" <[log in to unmask]>
Mon, 10 May 1999 13:16:48 -0600
text/plain (88 lines)
I've done some experiments on this.  This is the behavior I detect on GNAT
3.11p (Windows 98).

If I initialize both the Unbounded_String(s) to Null_Unbounded_String and
explicitly override Swap in Car with the exact same code, then it works

Perhaps someone else can enlighten as to why this behavior occurs (may be a
bug?-- consider sending to [log in to unmask]).  I added a dummy e1 package


-----Original Message-----
From: "Daniel Wengelin" <[log in to unmask]>
[mailto:[log in to unmask]]
Sent: Monday, May 10, 1999 1:07 PM
To: SMTP@ah@Servers[<[log in to unmask]>]
Subject: Why do I get program error?

Please, could anyone see the probably obvious
reason why this should terminate with Program_Error.
It's basically "from the book" but I got some odd results.
It compiles without any warnings, see below.

E:\dawe\CELSIUS\STRICS\Ada95-kurs>gnatmake e1-main.adb
gcc -c e1-main.adb
gcc -c
gcc -c
gcc -c e1-vehicle.adb
gnatbind -x e1-main.ali
gnatlink e1-main.ali




------------------------------------short source
with Ada.Strings.Unbounded; use Ada.Strings.Unbounded;
package E1.Vehicle is
   type Object is tagged
      end record;
   procedure Swap (L,R : in out Object);
end E1.Vehicle;

package body E1.Vehicle is
   procedure Swap (L, R : in out Object)
      Temp: Object;
      L := R;
      R := Temp;
   end Swap;
end E1.Vehicle;

with Ada.Strings.Unbounded; use Ada.Strings.Unbounded;
with E1.Vehicle;
package E1.Car is
   type Object is new E1.Vehicle.Object with
         Registration : Unbounded_String;
      end record;
end E1.Car;

--missing from original post
package e1 is
  dummy : integer := 0;
end e1;

with Ada.Strings.Unbounded;use Ada.Strings.Unbounded;
with E1.Car;
procedure Main is
   A_Car, Another_Car : E1.Car.Object;
   A_Car := (To_Unbounded_String("putte"),
   Another_Car := (To_Unbounded_String("pelle"),
   E1.CAR.Swap (A_Car ,Another_Car);
end Main;