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.9 required=5.0 tests=BAYES_00,FORGED_GMAIL_RCVD, FREEMAIL_FROM autolearn=no autolearn_force=no version=3.4.4 X-Google-Thread: 103376,8a7b744efabb21c4,start X-Google-Attributes: gid103376,domainid0,public,usenet X-Google-Language: ENGLISH,ASCII-7-bit Path: g2news1.google.com!news3.google.com!postnews.google.com!m73g2000hsh.googlegroups.com!not-for-mail From: Gene Newsgroups: comp.lang.ada Subject: Out parameters and unconstrained variant types Date: Thu, 26 Jun 2008 17:22:29 -0700 (PDT) Organization: http://groups.google.com Message-ID: NNTP-Posting-Host: 70.101.174.178 Mime-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit X-Trace: posting.google.com 1214526150 26052 127.0.0.1 (27 Jun 2008 00:22:30 GMT) X-Complaints-To: groups-abuse@google.com NNTP-Posting-Date: Fri, 27 Jun 2008 00:22:30 +0000 (UTC) Complaints-To: groups-abuse@google.com Injection-Info: m73g2000hsh.googlegroups.com; posting-host=70.101.174.178; posting-account=-BkjswoAAACC3NU8b6V8c50JQ2JBOs04 User-Agent: G2/1.0 X-HTTP-UserAgent: Mozilla/4.0 (compatible; MSIE 7.0; Windows NT 5.1; .NET CLR 1.1.4322; .NET CLR 2.0.50727; .NET CLR 3.0.04506.30),gzip(gfe),gzip(gfe) Xref: g2news1.google.com comp.lang.ada:897 Date: 2008-06-26T17:22:29-07:00 List-Id: Hello friends, I would like to do something like: type Conditional_Result (Exists : Boolean := False) is record case Exists is when True => Value : Natural; when False => null; end record; procedure Do_Something(x : in Natural; rtn : out Conditional_Result) is begin if x = 0 then rtn := (Exists => False); else rtn := (Exists => True; Value => x + 1); end if; end; procedure Foo is rtn : Conditional_Result; begin Do_Something(0, rtn); if rtn.Exists then Put_Line("Yes!"); end if; Do_Something(1, rtn); if rtn.Exists then Put_Line("Yes!"); end if; end; ALRM 2005 and Barnes seem to say the procedure Do_Something will know that rtn in foo is unconstrained and allow both calls to succeed. In GNAT 2007, the second call fails with a constraint error at the assignment to rtn. Can you tell me what I'm missing? Thanks!