Talk About Network



Register and Login
Nick
Password
Register create new account Sign up is FREE and you can post replies, new topics, bookmark posts and more!
Recover lost password


Programming > Ada > Compiler bug
Latest [ Topics | Posts ] Archive Post A New Topic Post a Reply
<< Topic < Post Post 1 of 5 Topic 5631 of 5697
Post > Topic >>

Compiler bug

by Maciej Sobczak <see.my.homepage@[EMAIL PROTECTED] > Apr 1, 2008 at 04:52 AM

Consider a trivial example with composition of interfaces:

with Ada.Text_IO;

procedure A is

   package Stuff is

      type Base_1 is interface;
      procedure P_1 (X : in Base_1) is abstract;

      type Base_2 is interface;
      procedure P_2 (X : in Base_2) is abstract;

      type Middle is interface and Base_1 and Base_2;

      type Concrete is new Middle with null record;
      procedure P_1 (X : in Concrete);
      procedure P_2 (X : in Concrete);

      function Make_Concrete return Concrete;

   end Stuff;

   package body Stuff is

      procedure P_1 (X : in Concrete) is
      begin
         Ada.Text_IO.Put_Line ("Concrete.P_1");
      end P_1;

      procedure P_2 (X : in Concrete) is
      begin
         Ada.Text_IO.Put_Line ("Concrete.P_2");
      end P_2;

      function Make_Concrete return Concrete is
         C : Concrete;
      begin
         return C;
      end Make_Concrete;

   end Stuff;

   use Stuff;

   B_1 : Base_1'Class := Make_Concrete;
   B_2 : Base_2'Class := Make_Concrete;

begin
   B_1.P_1;
   B_2.P_2;
end;

$ gnatmake a
$ ./a
Concrete.P_1
Concrete.P_1
$

In other words, both calls dispatched to the same procedure.

Some experiments led me to the interesting observation:
Changing this:

      type Middle is interface and Base_1 and Base_2;

to this:

      type Middle is interface and Base_2 and Base_1;

results in:

$ ./a
Concrete.P_2
Concrete.P_2

Again, both calls dispatched to the same procedure, but now I know
that in both cases the dispatch goes to the *first* progenitor of the
Middle interface. Obviously against 3.9.4-1/b.

Things get particularly funny when the signatures of P_1 and P_2 are
different (say, they have different sets of parameters).

It all looks like the v-table got messed up.

$ gnatmake --version
GNATMAKE 4.4.0 20080314 (experimental) [trunk revision 133226]

It is the newest version I could find for my system.

--
Maciej Sobczak * www.msobczak.com * www.inspirel.com




 5 Posts in Topic:
Compiler bug
Maciej Sobczak <see.my  2008-04-01 04:52:50 
Re: Compiler bug
Ludovic Brenta <ludovi  2008-04-01 06:00:52 
Re: Compiler bug
Maciej Sobczak <see.my  2008-04-01 13:43:54 
Re: Compiler bug
"Alex R. Mosteo"  2008-04-02 13:39:23 
Re: Compiler bug
Per Sandberg <per.sand  2008-04-02 19:44:49 

Post A Reply:
  Go here to Signup

AddThis Feed Button


About - Advertising - Contact - Frequently Asked Questions - Privacy Policy - Terms of Use - Signup

Contact
tan12V112 Wed May 14 10:56:08 CDT 2008.