This is GCC Bugzilla
This is GCC Bugzilla Version 2.20+
View Bug Activity | Format For Printing | Clone This Bug
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;
Same when using gcc version 4.3.0 20061130 (experimental) The only invariant in the output is that As > Bs.
lowering severity