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.3 required=5.0 tests=BAYES_00,INVALID_MSGID autolearn=no autolearn_force=no version=3.4.4 X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 103376,9d66743a9fdd96bd X-Google-Attributes: gid103376,public From: "Samuel T. Harris" Subject: Re: question about functions Date: 2000/01/21 Message-ID: <38889682.ACA87787@Raytheon.com>#1/1 X-Deja-AN: 575796719 Content-Transfer-Encoding: 7bit References: <8690q7$8tc$1@news.mgn.net> X-Accept-Language: en Content-Type: text/plain; charset=us-ascii Organization: Raytheon Aerospace Engineering Services Mime-Version: 1.0 Newsgroups: comp.lang.ada Date: 2000-01-21T00:00:00+00:00 List-Id: tmoran@bix.com wrote: > > function ADD (A, B : in T) return T is > tmp : T; > begin > -- call a procedure which use directly the hardware : > proc (a'address, b'address, tmp'address); > return tmp; > end ADD; The compiler may pass A and B in registers instead of on the stack. In this case a'address and b'address will cause runtime errors. VADS on SGI IRIX causes a either a bus error or segmentation fault (I can't remember now) for a similar subprogram we needed. To get around this, you need temps for A and B, ala ... function ADD (A, B : in T) return T is temp_a : t := a; temp_b : t := b; result : t; begin proc (temp_a'address, temp_b'address, result'address); return result; end; In our case VADS was not smart enough to recognize that the usage of the parameters includes a 'address attribution which should preclude passing A and B in registers. Given the other complex data flow analysis employed by the compiler for other optimizations, this seems a reasonable check. Of course VADS is Ada 83. Perhaps the language laywers in the news group can expound on any new Ada 95 rules which eliminates this situation? -- Samuel T. Harris, Principal Engineer Raytheon, Aerospace Engineering Services "If you can make it, We can fake it!"