comp.lang.ada
 help / color / mirror / Atom feed
From: Adam Beneschan <adam@irvine.com>
Subject: Re: Unchecked_Union with empty variant
Date: Mon, 16 Mar 2009 08:16:18 -0700 (PDT)
Date: 2009-03-16T08:16:18-07:00	[thread overview]
Message-ID: <715cf067-8dfa-40d8-a6f2-1237ad4234b6@q30g2000prq.googlegroups.com> (raw)
In-Reply-To: gpj045$4dc$1@octagram.motzarella.org

On Mar 15, 6:34 am, Ivan Levashew <octag...@bluebottle.com> 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






  reply	other threads:[~2009-03-16 15:16 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2009-03-15 13:34 Unchecked_Union with empty variant Ivan Levashew
2009-03-16 15:16 ` Adam Beneschan [this message]
2009-03-16 21:52 ` Stephen Leake
2009-03-17  7:21   ` Ivan Levashew
  -- strict thread matches above, loose matches on Subject: below --
2009-03-15 13:10 Ivan Levashew
2009-03-15 13:02 Ivan Levashew
replies disabled

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox