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.9 required=5.0 tests=BAYES_00,FREEMAIL_FROM autolearn=ham autolearn_force=no version=3.4.4 X-Google-Thread: 103376,3bcd1f427235dca8 X-Google-Attributes: gid103376,public X-Google-Language: ENGLISH,ASCII-7-bit Path: g2news1.google.com!news2.google.com!news.maxwell.syr.edu!news.tele.dk!news.tele.dk!small.news.tele.dk!not-for-mail Sender: malo@0x5358ef74.boanxx18.adsl-dhcp.tele.dk Newsgroups: comp.lang.ada Subject: Re: expect procedure name in procedure call(newbie) References: <1104316623.493536.111460@f14g2000cwb.googlegroups.com> <87hdm5xq7x.fsf@deneb.enyo.de> <1104325404.761331.70990@f14g2000cwb.googlegroups.com> From: Mark Lorenzen Date: 29 Dec 2004 14:24:45 +0100 Message-ID: User-Agent: Gnus/5.09 (Gnus v5.9.0) Emacs/21.3 MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Organization: TDC Totalloesninger NNTP-Posting-Host: 83.88.239.116 X-Trace: 1104326685 dtext02.news.tele.dk 172 83.88.239.116:56669 X-Complaints-To: abuse@post.tele.dk Xref: g2news1.google.com comp.lang.ada:7290 Date: 2004-12-29T14:24:45+01:00 List-Id: "R" writes: > OK so i added new variable ret(Integer) and added: > ret := testclass.Create(object, 10); > > but now Create raises an expception: CONSTRAINT_ERROR : testclass.adb:5 > access check failed > > where the Create looks like: > function Create(this: rec1_Access; s: Integer) return Integer is > begin > this.field := s; -- this is the 5th line - access check error > return this.field; > end Create; > > basicly the codes are the same from my first post - I only folow Your > instuction not to ignore the return value. > > Is my access type wrong? it point to rec1 tagged record. > thanks in advance for Your help > best regards R The parameter 'this' is of an access type. As the actual parameter you pass a non-initialised variable. In Ada, all variables of access type have the value 'null' by default. So you pass 'Create' a null value and the dereference it. Your example seems to be a translation of a C++ function. I would do the following instead: 1) Make 'Create' a procedure instead of a function with the following signature: Create (This : out Rec1; S : in Integer); 2) procedure Main is Object : Testclass.Rec1; begin Testclass.Create(Object, 10); end Main; Do not fiddle around with pointers as much as you do. It seems like you try to program in Ada the C++ way. - Mark Lorenzen