Mon, 10 May 1999 13:16:48 -0600
|
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
fine.
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
below.
--Martin
-----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 e1.ads
gcc -c e1-car.ads
gcc -c e1-vehicle.adb
gnatbind -x e1-main.ali
gnatlink e1-main.ali
E:\dawe\CELSIUS\STRICS\Ada95-kurs>e1-main
raised PROGRAM_ERROR : EXCEPTION_ACCESS_VIOLATION
E:\dawe\CELSIUS\STRICS\Ada95-kurs>
------------------------------------short source
follows-----------------------------------
with Ada.Strings.Unbounded; use Ada.Strings.Unbounded;
package E1.Vehicle is
type Object is tagged
record
Name:Unbounded_String;
end record;
procedure Swap (L,R : in out Object);
end E1.Vehicle;
package body E1.Vehicle is
procedure Swap (L, R : in out Object)
is
Temp: Object;
begin
Temp:=L;
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
record
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;
begin
A_Car := (To_Unbounded_String("putte"),
To_Unbounded_String("abc123"));
Another_Car := (To_Unbounded_String("pelle"),
To_Unbounded_String("gef789"));
E1.CAR.Swap (A_Car ,Another_Car);
end Main;
|
|
|