comp.lang.ada
 help / color / mirror / Atom feed
* Compiler bug
@ 2008-04-01 11:52 Maciej Sobczak
  2008-04-01 13:00 ` Ludovic Brenta
                   ` (2 more replies)
  0 siblings, 3 replies; 18+ messages in thread
From: Maciej Sobczak @ 2008-04-01 11:52 UTC (permalink / raw)


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



^ permalink raw reply	[flat|nested] 18+ messages in thread
* Compiler Bug
@ 2007-12-04 21:58 REH
  2007-12-04 22:25 ` Lucretia
  0 siblings, 1 reply; 18+ messages in thread
From: REH @ 2007-12-04 21:58 UTC (permalink / raw)


I have an issue that my compiler vendor is trying to tell me is not a
bug.  I have two functions.  They both have a local variable of the
same name.  One calls the other (which is inlined).  The compiler
treats the variable in the caller as if it is of the same type as the
one in the callee.  Because of this, we get a constraint_error
exception.  The problem goes away when the pragma inline is removed.
The vendor is trying to tell me that this behavior is acceptable and
correct.  I do not believe that it is.  Please tell me who it right.

REH



^ permalink raw reply	[flat|nested] 18+ messages in thread

end of thread, other threads:[~2008-04-02 17:44 UTC | newest]

Thread overview: 18+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2008-04-01 11:52 Compiler bug Maciej Sobczak
2008-04-01 13:00 ` Ludovic Brenta
2008-04-01 20:43   ` Maciej Sobczak
2008-04-02 11:39 ` Alex R. Mosteo
2008-04-02 17:44 ` Per Sandberg
  -- strict thread matches above, loose matches on Subject: below --
2007-12-04 21:58 Compiler Bug REH
2007-12-04 22:25 ` Lucretia
2007-12-04 22:32   ` REH
2007-12-04 22:45     ` Randy Brukardt
2007-12-04 22:49       ` REH
2007-12-04 22:54       ` Adam Beneschan
2007-12-05  9:46         ` Samuel Tardieu
2007-12-05 16:07           ` Adam Beneschan
2007-12-06  3:30             ` Randy Brukardt
2007-12-06  3:30             ` Randy Brukardt
2007-12-04 22:45     ` Randy Brukardt
2007-12-06  6:51     ` Keith Thompson
2007-12-06 16:48       ` REH

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