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,LOTS_OF_MONEY autolearn=ham autolearn_force=no version=3.4.4 X-Google-Thread: 103376,c370342fe303517b X-Google-Attributes: gid103376,public X-Google-Language: ENGLISH,ASCII-7-bit Path: g2news2.google.com!news3.google.com!border1.nntp.dca.giganews.com!nntp.giganews.com!local01.nntp.dca.giganews.com!nntp.megapath.net!news.megapath.net.POSTED!not-for-mail NNTP-Posting-Date: Mon, 05 Feb 2007 19:47:07 -0600 From: "Randy Brukardt" Newsgroups: comp.lang.ada References: <1170516037.435847.326440@p10g2000cwp.googlegroups.com> Subject: Re: C Interface example Date: Mon, 5 Feb 2007 19:48:31 -0600 X-Priority: 3 X-MSMail-Priority: Normal X-Newsreader: Microsoft Outlook Express 6.00.2800.1807 X-MIMEOLE: Produced By Microsoft MimeOLE V6.00.2800.1807 Message-ID: NNTP-Posting-Host: 64.32.209.38 X-Trace: sv3-ltFhOaxDQFcnvGkG1yBX9OtAzypkgMvnYjFi56+ez6vD+RhBD6duKG8d1pjezUcB9mWElIvYhwtQ5Ui!P7DagXLMHIwX8cknMMAeFoI84mWtKlDCGEBsMFUKGSnWytew/2xURolvcmFPDcOH5kJb0hg1Pbd4!pzzFXBaUK/UF3w== X-Complaints-To: abuse@megapath.net X-DMCA-Complaints-To: abuse@megapath.net X-Abuse-and-DMCA-Info: Please be sure to forward a copy of ALL headers X-Abuse-and-DMCA-Info: Otherwise we will be unable to process your complaint properly X-Postfilter: 1.3.32 Xref: g2news2.google.com comp.lang.ada:8995 Date: 2007-02-05T19:48:31-06:00 List-Id: "Jeffrey R. Carter" wrote in message news:BsKxh.1174338$084.631125@attbi_s22... > Maciej Sobczak wrote: > > > > What about assigning something to Result and not using Result? > > That doesn't get through with some pedantic warning switches. > > True, you may get a warning, just as you may about not changing To. But > it's perfectly legal, portable Ada. Well, it's legal, and it is portable in this case, but it is a bad habit to get into. (That's why the pedantic warning.) 11.6(5) allows the removal of code that raises exceptions if the result is not used. I don't think it applies to external code like C, but it certainly does apply to Ada code. (And, like all points about 11.6, it's likely to result in a roaring argument; no one is quite sure what is and is not allowed.) Anyway, the point is that if you just drop the result on the floor, the Ada compiler might be allowed to omit the call, too. So it is always best to use the result somehow. In this case, test it for null and do something explicit: if Result = null then raise Internal_Error; end if; where Internal_Error is an appropriately defined exception. Randy.