Bug List: (This bug is not in your last search results)   Show last search results      Search page      Enter new bug
Bug#: 30078
Product:  
Component:  
Status: UNCONFIRMED
Resolution:
Assigned To: Not yet assigned to anyone <unassigned@gcc.gnu.org>
Host:
Reported against  
Priority:  
Severity:  
Target Milestone:  
 
 
Target:
Reporter: Christopher Orihuela <orihuela@idecnet.com>
Add CC:
CC:
Remove selected CCs
Build:
URL:
Summary:
Keywords:
Known to work:
Known to fail:

Attachment Description Type Created Size Actions
Create a New Attachment (proposed patch, testcase, etc.) View All

Bug 30078 depends on: Show dependency tree
Show dependency graph
Bug 30078 blocks:

Additional Comments:






Mark bug as waiting for feedback



    

    

View Bug Activity   |   Format For Printing   |   Clone This Bug


Description:   Last confirmed: Opened: 2006-12-05 21:41
The attached file contains a procedure that shows weird problems mixing tasks
and recursion.
A correct program behavior would be showing the same number of As and Bs, but
instead, for values of IMax > 4 we get different counts.

gcc version 3.4.6 for GNAT GPL 2006 (20060522) running on windows 2000/WinXP
gcc version 3.4.6 for GNAT GPL 2006 (20060522) running on linux/CentOS.



With Ada.Text_IO;
Use Ada.Text_IO;

Procedure My_Proc is

   protected type Counter is
      Procedure IncA;
      Procedure IncB;
      function GetA return Natural;
      function GetB return Natural;
   private
      A, B: Natural := 0;
   end Counter;

   protected body Counter is
      Procedure IncA is
      begin
         A := A+1;
      end IncA;
      Procedure IncB is
      begin
         B := B+1;
      end IncB;
      function GetA return Natural is
      begin
         return A;
      end GetA;
      function GetB return Natural is
      begin
         return B;
      end GetB;
   end Counter;

   MyCounter : Counter;

   Procedure Recursive (I : Natural; MaxI : Natural) is
   begin

      if (I >= MaxI) then
           return;
      end if;

      MyCounter.IncA;
      MyCounter.IncA;
      declare
         Task My_Recursive_Task;
         Task Body My_Recursive_Task is
         begin
            Recursive(I+1, MaxI);
            MyCounter.IncB;
         exception
            when Others =>
               Put_Line ("Exception");
         end My_Recursive_Task;

      begin
         Recursive(I+1, MaxI);
         MyCounter.IncB;
      exception
         when Others =>
            Put_Line ("Exception");
      end;
   end Recursive;

begin
   Recursive (1, 6);
   Put_Line("A: " & Integer'Image(MyCounter.GetA));
   Put_Line("B: " & Integer'Image(MyCounter.GetB));
end My_Proc;

------- Comment #1 From Georg Bauhaus 2006-12-05 22:40 -------
Same when using gcc version 4.3.0 20061130 (experimental)

The only invariant in the output is that As > Bs.

------- Comment #2 From Arnaud Charlet 2007-05-02 15:50 -------
lowering severity

Bug List: (This bug is not in your last search results)   Show last search results      Search page      Enter new bug