From mboxrd@z Thu Jan 1 00:00:00 1970 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on polar.synack.me X-Spam-Level: * X-Spam-Status: No, score=1.2 required=5.0 tests=BAYES_00,CTE_8BIT_MISMATCH, INVALID_MSGID,REPLYTO_WITHOUT_TO_CC autolearn=no autolearn_force=no version=3.4.4 X-Google-Language: ENGLISH,ASCII X-Google-Thread: 103376,bd1a17edc1ccb2d6,start X-Google-Attributes: gid103376,public From: Ullar Kask Subject: Aggregate assignment problem with gnat under irix Date: 1996/05/31 Message-ID: #1/1 X-Deja-AN: 157804003 content-type: TEXT/PLAIN; charset=ISO-8859-1 organization: The University of Texas at Austin, Austin, Texas mime-version: 1.0 reply-to: ullar@einstein.ph.utexas.edu newsgroups: comp.lang.ada Date: 1996-05-31T00:00:00+00:00 List-Id: 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/