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=0.2 required=5.0 tests=BAYES_00,INVALID_MSGID, REPLYTO_WITHOUT_TO_CC autolearn=no autolearn_force=no version=3.4.4 X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 103376,1965f0d49c06096e,start X-Google-Attributes: gid103376,public From: jconley@mindspring.com (James Conley) Subject: problem with constrained arrays in descritiate records w/ GNAT305 Date: 1996/10/21 Message-ID: <54f3al$9bh@camel2.mindspring.com>#1/1 X-Deja-AN: 190910371 organization: MindSpring Enterprises, Inc. x-server-date: 21 Oct 1996 05:56:37 GMT reply-to: jconley@mindspring.com newsgroups: comp.lang.ada Date: 1996-10-21T05:56:37+00:00 List-Id: I sure hope that someone around here can help me out. I am writing a program for my Ada Data Structures class where I have to implement a Polynomial package and I'm using GNAT for MSDOS 305s under win95 and every time I try this program it crashes upon compilation. The version below will work & compile but if I remove ANY of the commented lines in the main procedure (even the ones right after the begin statement that duplicate lines further down) it will crash upon compilation with the statement not enought memory for compiler - I don't understand why I cannot print the ary'first twice without breaking my memory!!!!??? Does anyone here understand what I am doing wrong or if mabey this compiler has a bug in it? If you have any idea what I am doing wrong please let me know via email as I dont read this group but once a week. Thanks! james jconley@mindspring.com with text_io; use text_io; procedure prob is type real is new float; package my_real_io is new float_io(real); package my_int_io is new integer_io(integer); use my_real_io; use my_int_io; type sign_type is (neg,pos); subtype index is integer range 0..100; type monomial_type is record constant_factor:real; power:integer; sign:sign_type:=pos; end record; type monomial_ary is array (index range <>) of monomial_type; type polynomial (num:index:=0) is record Ary:monomial_ary (0..num); end record; -- writes a polynomial to std_out procedure put(poly_in:in polynomial) is begin put("hello, about to write a polynomial"); for i in poly_in.ary'range loop if poly_in.ary(i).sign=pos then put("+"); else put("-"); end if; put(poly_in.ary(i).constant_factor); if poly_in.ary(i).power=0 then null; elsif poly_in.ary(i).power=1 then put("x"); else put("x^"); put(poly_in.ary(i).power); end if; end loop; end put; test_poly:polynomial(num=>2); begin --prob/main --put("first is"); --put(test_poly.ary'first); -- this will crash if uncommented!!!??? --new_line; --test_poly.ary(1):=(3.0,3,neg); all these --test_poly.ary(0).power:=3; lines cause it to crash!? --test_poly.ary(0).constant_factor:=3.0; --test_poly.ary(1).sign:=pos; --test_poly.ary(1).power:=2; --test_poly.ary(1).constant_factor:=2.0; --test_poly.ary(2).sign:=neg; --test_poly.ary(2).power:=1; --test_poly.ary(2).constant_factor:=1.0; put("hello world"); new_line; put ("first="); put(test_poly.ary'first); new_line; put ("last="); put(test_poly.ary'last); new_line; --test_poly.ary(0):=2; --test_poly.ary(0).constant_factor:=2.0; put("hello"); new_line; end prob;