From: Ullar Kask <ullar@einstein.ph.utexas.edu>
Subject: Aggregate assignment problem with gnat under irix
Date: 1996/05/31
Date: 1996-05-31T00:00:00+00:00 [thread overview]
Message-ID: <Pine.SGI.3.93.960531171236.29298A-100000@einstein.ph.utexas.edu> (raw)
Hello,
I am doing numerical simulations using Ada and encoutered a problem with
aggregate assignment. The same type of statement, viz.,
A.all := (others => (others => 0.0));
where A.all is an NxN array (declared as unconstrained), works great in simple
procedures but fails in a task body. I don't understand what may be
the reason.
To be more specific, consider the following piece of code (compiles cleanly
with irix5.3 binary distribution of gnat 3.04 under irix5.2):
--------------------------------------------------------------------------------
with Ada.Text_IO, Interfaces.Fortran, Ada.Exceptions;
use Ada.Text_IO;
procedure Aggr_Tst is
subtype Real is Interfaces.Fortran.Real;
type Matrix_Type is array (Integer range <>, Integer range <>) of Real;
pragma Convention( Fortran, Matrix_Type);
type Matrix_Type_Access is access Matrix_Type;
type Grid_Type is (COARSE, MEDIUM, FINE);
Lhs : array (Grid_Type) of Matrix_Type_Access;
Grid_Length : array (Grid_Type) of Positive;
Grid : Grid_Type;
task Some_Task is
entry Entry_Point( G : in Grid_Type);
end Some_Task;
task body Some_Task is
Grid : Grid_Type;
begin
accept Entry_Point( G : in Grid_Type) do
Grid := G;
end Entry_Point;
--
-- Some work is being done here with Lhs(Grid).all
-- After that, try to initialize it again:
begin
-- The following statement raises STORAGE_ERROR:
Lhs(Grid).all := (others => (others => 0.0));
-- So does this:
-- Lhs(Grid).all := (Lhs(Grid).all'RANGE(1) =>
-- (Lhs(Grid).all'RANGE(2) => 0.0));
-- And this:
-- Lhs(Grid).all := (-Grid_Length(Grid) .. Grid_Length(Grid) =>
-- (-Grid_Length(Grid) .. Grid_Length(Grid) => 0.0));
-- Only the following double-loop does the job:
-- for I in Lhs(Grid).all'RANGE(1) loop
-- for J in Lhs(Grid).all'RANGE(2) loop
-- Lhs(Grid)(I,J) := 0.0;
-- end loop;
-- end loop;
exception
when O: others =>
Put_Line( "***Lhs initialization failed!*** Exception " &
Ada.Exceptions.Exception_Name(O) & " raised in task body.");
raise;
end;
Put_Line( "Lhs initialized again in task body.");
end Some_Task;
begin
-- Some values assigned to Grid and Grid_Length(Grid):
Grid := COARSE;
Grid_Length(Grid) := 100;
-- Allocate matrix:
Lhs(Grid) := new Matrix_Type(-Grid_Length(Grid) .. Grid_Length(Grid),
-Grid_Length(Grid) .. Grid_Length(Grid));
-- Initialize matrix:
begin
Lhs(Grid).all := (others => (others => 0.0)); -- This works fine
exception -- No exceptions raised here
when Q: others =>
Put_Line( "***Lhs initialization failed!*** Exception " &
Ada.Exceptions.Exception_Name(Q) & " raised in main procedure");
raise;
end;
Put_Line( "Lhs initialized in main procedure.");
-- Do some work with the matrix:
Some_Task.Entry_Point( Grid);
end Aggr_Tst;
------------------------------END OF CODE SAMPLE--------------------------------
Has the STORAGE_ERROR raised in the task body (under irix) something to do
with the size of the task stack? How it happens that such an aggregate
assignment is possible outside a task body but fails inside?
Any comments on the issue are appreciated!
Thanks a lot!
================================================================================
�llar Kask
Center for Relativity, University of Texas, Austin
email: ullar@einstein.ph.utexas.edu
ph. (512) 471-5905
http://wwwrel.ph.utexas.edu/Members/ullar/
next reply other threads:[~1996-05-31 0:00 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
1996-05-31 0:00 Ullar Kask [this message]
1996-06-02 0:00 ` Aggregate assignment problem with gnat under irix Vance Christiaanse
1996-06-03 0:00 ` Keith Thompson
1996-06-02 0:00 ` David C. Hoos, Sr.
1996-06-02 0:00 ` Vance Christiaanse
replies disabled
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox