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,eb6a9ac6a74a256c X-Google-Attributes: gid103376,domainid0,public,usenet X-Google-Language: ENGLISH,ASCII-7-bit Path: g2news1.google.com!postnews.google.com!q30g2000prq.googlegroups.com!not-for-mail From: Adam Beneschan Newsgroups: comp.lang.ada Subject: Re: Unchecked_Union with empty variant Date: Mon, 16 Mar 2009 08:16:18 -0700 (PDT) Organization: http://groups.google.com Message-ID: <715cf067-8dfa-40d8-a6f2-1237ad4234b6@q30g2000prq.googlegroups.com> References: NNTP-Posting-Host: 66.126.103.122 Mime-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit X-Trace: posting.google.com 1237216579 18301 127.0.0.1 (16 Mar 2009 15:16:19 GMT) X-Complaints-To: groups-abuse@google.com NNTP-Posting-Date: Mon, 16 Mar 2009 15:16:19 +0000 (UTC) Complaints-To: groups-abuse@google.com Injection-Info: q30g2000prq.googlegroups.com; posting-host=66.126.103.122; posting-account=duW0ogkAAABjRdnxgLGXDfna0Gc6XqmQ User-Agent: G2/1.0 X-HTTP-UserAgent: Mozilla/5.0 (X11; U; Linux x86_64; en-US; rv:1.7.12) Gecko/20050922 Fedora/1.7.12-1.3.1,gzip(gfe),gzip(gfe) Xref: g2news1.google.com comp.lang.ada:4145 Date: 2009-03-16T08:16:18-07:00 List-Id: On Mar 15, 6:34 am, Ivan Levashew wrote: > [Check_Unions.adb] > ~~~~~~~~ > procedure Check_Unions is > > type Complex_Record (Kind : Integer := 0) is record > Constant_Part : Character; > Constant_Part2 : Character; > case Kind is > when 0 => > Variant_Part1 : Character; > when 1 => > Variant_Part2 : Character; > when 2 => > Variant_Part3 : Character; > when others => > null; > end case; > end record; > > pragma Unchecked_Union (Complex_Record); > > begin > null; > end Check_Unions; > ~~~~~~~~ > > It gives an error: > C:\...ramming\GEMA-Win32API\Ada_test>gnatmake -gnat05 Check_Unions.adb > gcc -c -gnat05 check_unions.adb > check_unions.adb:14:04: Unchecked_Union may not have empty component list > gnatmake: "check_unions.adb" compilation error > > What's the problem? > > I can't see any words "empty" or "null" here: > > http://www.adaic.com/standards/05aarm/html/AA-B-3-3.html I can't find any rule that makes this illegal. The error message indicates, though, that someone at GNAT thought it was illegal---i.e. it's not simply a "bug" due to incorrectly implementating the requirements, but was rather a misinterpretation of the standard. But either way, I think the compiler is wrong. -- Adam