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 autolearn=ham autolearn_force=no version=3.4.4 X-Google-Thread: 103376,c80e6f742e73478f,start X-Google-NewGroupId: yes X-Google-Attributes: gida07f3367d7,domainid0,public,usenet X-Google-Language: ENGLISH,ASCII-7-bit Path: g2news1.google.com!postnews.google.com!g26g2000yqn.googlegroups.com!not-for-mail From: Ludovic Brenta Newsgroups: comp.lang.ada Subject: Ensuring postconditions in the face of exceptions Date: Fri, 12 Mar 2010 01:13:45 -0800 (PST) Organization: http://groups.google.com Message-ID: <820d96c0-5d67-4b8c-8c5b-811ca4f1127e@g26g2000yqn.googlegroups.com> NNTP-Posting-Host: 153.98.68.197 Mime-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1 X-Trace: posting.google.com 1268385226 4921 127.0.0.1 (12 Mar 2010 09:13:46 GMT) X-Complaints-To: groups-abuse@google.com NNTP-Posting-Date: Fri, 12 Mar 2010 09:13:46 +0000 (UTC) Complaints-To: groups-abuse@google.com Injection-Info: g26g2000yqn.googlegroups.com; posting-host=153.98.68.197; posting-account=pcLQNgkAAAD9TrXkhkIgiY6-MDtJjIlC User-Agent: G2/1.0 X-HTTP-UserAgent: Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.9.1.8) Gecko/20100202 Firefox/3.5.8,gzip(gfe),gzip(gfe) Xref: g2news1.google.com comp.lang.ada:9540 Date: 2010-03-12T01:13:45-08:00 List-Id: Consider the procedure: type T is private; -- completion elided generic with procedure Visit (Object : in out T); procedure Refresh (Object : in out T; Dirty : in out T) is begin if Dirty then Visit (Object); Dirty := False; end if; exception when others => Dirty := True; -- warnings here raise; end Refresh; GNAT says: warning: assignment to pass-by-copy formal may have no effect warning: "raise" statement may result in abnormal return (RM 6.4.1(17)) The reason for the exception handler is to enforce a postcondition that Dirty must be True if Visit raises an exception. However the warnings suggest that the postcondition cannot be enforced this way. How should I rewrite my code? -- Ludovic Brenta.