This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
[Bug ada/30078] New: problems mixing Tasks and recursion
- From: "orihuela at idecnet dot com" <gcc-bugzilla at gcc dot gnu dot org>
- To: gcc-bugs at gcc dot gnu dot org
- Date: 5 Dec 2006 21:41:25 -0000
- Subject: [Bug ada/30078] New: problems mixing Tasks and recursion
- Reply-to: gcc-bugzilla at gcc dot gnu dot org
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;
--
Summary: problems mixing Tasks and recursion
Product: gcc
Version: unknown
Status: UNCONFIRMED
Severity: major
Priority: P3
Component: ada
AssignedTo: unassigned at gcc dot gnu dot org
ReportedBy: orihuela at idecnet dot com
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=30078