This is a rewrite of the original answer, now that we know that the task type in
question is discriminated.
You are passing a value to each task via a 'discriminant' without a default, which makes the task type unconstrained; you can't declare an object of the type without supplying a value for the discriminant (and supplying a default wouldn't help, because once the object has been created the discriminant can't be changed).
One common approach to this uses access types:
with Ada.Integer_Text_IO;
with Ada.Text_IO;
procedure Maciek is
task type T (Param : Integer);
type T_P is access T;
type My_Arr is array (Integer range <>) of T_P;
task body T is
begin
Ada.Text_IO.Put_Line ("t" & Param'Img);
end T;
N, M : Integer;
begin
Ada.Text_IO.Put ("number of tasks: ");
Ada.Integer_Text_IO.Get (N);
Ada.Text_IO.Put ("parameter: ");
Ada.Integer_Text_IO.Get (M);
declare
-- Create an array of the required size and populate it with
-- newly allocated T's, each constrained by the input
-- parameter.
Arr : My_Arr (1 .. N) := (others => new T (Param => M));
begin
null;
end;
end Maciek;
You may need to deallocate the new
ed tasks once they are completed; in the code above, the tasks' memory is leaked on exit from the declare
block.