From: Victor Porton <porton@narod.ru>
Subject: Re: Unchecked_Union record inside an other record - trouble
Date: Fri, 08 Aug 2014 23:28:13 +0300
Date: 2014-08-08T23:28:13+03:00 [thread overview]
Message-ID: <ls3bsp$p0j$1@speranza.aioe.org> (raw)
In-Reply-To: fkaFv.217999$L6.107395@fx08.iad
Shark8 wrote:
> On 08-Aug-14 14:12, Victor Porton wrote:
>> You forgot "with Unchecked_Union". Certainly your code does not work.
>
> There's no unchecked union on T2, that was T in your example.
>
>>
>> type T(K: Kind) is
>> record
>> case K is
>> when First => I: int;
>> when Second => C: char;
>> end case;
>> end record
>> with Unchecked_Union, Convention=>C;
>>
>> type T2 is
>> record
>> Z: int;
>> Ob: T;
>> end record
>> with Convention=>C;
>
> See?
GNAT 4.9 produces no warnings for the below program.
Which compiler do you use? I suspect it is a bug in your compiler.
Or do we speak about different Ada code?
-- main.adb
with Interfaces.C; use Interfaces.C;
procedure Main is
type Kind is (First, Second);
type T(K: Kind := Kind'Last) is
record
case K is
when First =>
X: int;
when Second =>
Y: char;
end case;
end record
with Unchecked_Union, Convention=>C;
type Container is
record
Z: int;
R: T;
end record;
function P (C: Container) return char is
begin
return C.R.Y;
end;
begin
null;
end;
--
Victor Porton - http://portonvictor.org
next prev parent reply other threads:[~2014-08-08 20:28 UTC|newest]
Thread overview: 17+ messages / expand[flat|nested] mbox.gz Atom feed top
2014-08-08 15:36 Unchecked_Union record inside an other record - trouble Victor Porton
2014-08-08 16:01 ` Adam Beneschan
2014-08-08 16:56 ` Victor Porton
2014-08-08 18:52 ` Shark8
2014-08-08 19:56 ` Victor Porton
2014-08-08 20:06 ` Pascal Obry
2014-08-08 20:09 ` Shark8
2014-08-08 20:12 ` Victor Porton
2014-08-08 20:22 ` Shark8
2014-08-08 20:28 ` Victor Porton [this message]
2014-08-08 21:07 ` Shark8
2014-08-08 19:52 ` Victor Porton
2014-08-08 19:57 ` Adam Beneschan
2014-08-08 19:21 ` Per Sandberg
2014-08-08 20:01 ` Victor Porton
2014-08-08 21:23 ` Jeffrey Carter
2014-08-10 7:25 ` Per Sandberg
replies disabled
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox