* Re: type casting tagged types in the wrong
[not found] <md5:2007D2C08E89BD8AAF36D7DF96E5D7BE>
@ 1996-04-02 0:00 ` James A. Squire
0 siblings, 0 replies; 2+ messages in thread
From: James A. Squire @ 1996-04-02 0:00 UTC (permalink / raw)
Scott Moody <scott@PLATO.DS.BOEING.COM> wrote:
> I run this same program with GNAT 3.03 on solaris
> and it reports the error correctly:
>
> tmp.adb:24:14: downward conversion of tagged objects not allowed
> gnatmake: *** compilation failed.
>
> ----source:
[source snipped]
I just ran it myself against the same compiler on the same platform and
to my chagrin I got the same error message.
I had figured that the bug would be consistant. The place where I found
it
was in the Alert system that is partially coded in the Rationale. I
added code for the other subunits besides Handle, and then I switched
the overloads of Handle so that the one for Medium Alerts called the one
for High Alerts instead of the one for Alerts. I made sure the subunit
for Set_Alarm actually tried to read the extra field. In this case
there was no error on the line:
Handle (HA => High_Alert(MA));
I will send this off to report@gnat.com.
--
James Squire
MDA Avionics Tools & Processes
ja_squire@csehp3.mdc.com
"one of these days I'm going to better myself by going to Knight school"
^ permalink raw reply [flat|nested] 2+ messages in thread
* Re: type casting tagged types in the wrong direction
@ 1996-03-28 0:00 Tucker Taft
1996-03-29 0:00 ` type casting tagged types in the wrong Scott Moody
0 siblings, 1 reply; 2+ messages in thread
From: Tucker Taft @ 1996-03-28 0:00 UTC (permalink / raw)
James A. Squire (m193884@CSEHP3.MDC.COM) wrote:
: I have a question:
: Say I have something like:
: type A is tagged
: record
: X : ABC;
: Y : DEF;
: end record;
: type B is new A with
: record
: W : GHI;
: end record;
: type C is new B with
: record
: Z : JKL;
: end record;
: OK. Now, let's say that I forgot which type extends off of which, and I
: write a statement like this:
: Jim : C;
: Jane : B;
: Save : JKL;
: begin
: ...
: Jim := C (Jane);
This is illegal, by RM95 4.6(21-23).
: Save := Jim.Z;
: ...
: end;
: GNAT 3.03 compiles this statement. Is that really right?
No. GNAT should have complained at compile time about the conversion
from B to C. You may convert from B'Class to C (and then a run-time
check is performed), or you may convert from C to B, but a direct
conversion from B to C is illegal.
: ... Is Jim.Z defined?
Jim.Z is "defined," but the conversion on the previous line
is illegal, so who knows what code GNAT is generating for the
assignment to Jim.
: According to the LRM 4.6, the above is called a "view conversion". This
: raises the question, how do you take a type C view of a type B entity
: when type C looks for additional information?
You can't.
: Should a validated Ada95 compiler flag this usage? I realize that GNAT
: is not validated.
GNAT is validated, but validation doesn't guarantee bug-free
(nor does anything else I know of ;-).
This looks like a bug in GNAT, pure and simple. (It also *suggests*
that another ACVC test might be in order ;-).
: I would appreciate any expert or otherwise opinions that any of you have
: to offer.
: Thank you.
: --
: James Squire
: MDA Avionics Tools & Processes
: ja_squire@csehp3.mdc.com
: "one of these days I'm going to better myself by going to Knight school"
-Tucker Taft stt@inmet.com http://www.inmet.com/~stt/
Intermetrics, Inc. Cambridge, MA USA
^ permalink raw reply [flat|nested] 2+ messages in thread
* Re: type casting tagged types in the wrong
1996-03-28 0:00 type casting tagged types in the wrong direction Tucker Taft
@ 1996-03-29 0:00 ` Scott Moody
0 siblings, 0 replies; 2+ messages in thread
From: Scott Moody @ 1996-03-29 0:00 UTC (permalink / raw)
I run this same program with GNAT 3.03 on solaris
and it reports the error correctly:
tmp.adb:24:14: downward conversion of tagged objects not allowed
gnatmake: *** compilation failed.
----source:
procedure tmp is
type A is tagged
record
X : integer;
Y : integer;
end record;
type B is new A with
record
W : integer;
end record;
type C is new B with
record
Z : integer;
end record;
Jim : C;
Jane : B;
Save : integer;
begin
Jim := C (Jane);
Save := Jim.Z;
end;
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~1996-04-02 0:00 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
[not found] <md5:2007D2C08E89BD8AAF36D7DF96E5D7BE>
1996-04-02 0:00 ` type casting tagged types in the wrong James A. Squire
1996-03-28 0:00 type casting tagged types in the wrong direction Tucker Taft
1996-03-29 0:00 ` type casting tagged types in the wrong Scott Moody
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox