comp.lang.ada
 help / color / mirror / Atom feed
From: Simon Wright <simon.j.wright@mac.com>
Subject: Re: Enumeration representation clause surprise.
Date: Thu, 12 Jun 2008 21:52:56 +0100
Date: 2008-06-12T21:52:56+01:00	[thread overview]
Message-ID: <m27icuqst3.fsf@mac.com> (raw)
In-Reply-To: c3342a0b-2e81-4ac3-a994-35c18df3c3d6@e39g2000hsf.googlegroups.com

Mike Silva <snarflemike@yahoo.com> writes:

> I wonder then if this is an error at all.  IANALL, but if the
> program makes available your specified values when queried with the
> proper mechanism (in this case, unchecked conversion), then I don't
> see what difference it makes how it stores the representations in
> raw memory.

The only reason I have ever written representation clauses is to
ensure that the contents of raw memory are what some external hardware
(or software, eg at the other end of a network connection) requires
them to be. So I really really don't want the compiler to do anything
other than what I asked for; and if it can't, to reject the
representation loudly and fatally!

Given OP's declarations

   type Enum_T is (One, Two);
   for Enum_T use (One => 1, Two => 2);

   type Record_T is record
      A1 : Enum_T;
      A2 : Enum_T;
   end record;
   for Record_T use record
      A1 at 0 range 0 .. 0;
      A2 at 1 range 0 .. 7;
   end record;
   for Record_T'Size use 2 * 8;

   Foo : Record_T;

there's a huge difference between an unchecked conversion of the value
Foo.A1 to <whatever>, which might quite reasonably have the bias
removed, and UC of the value Foo as a whole, which wouldn't.



  reply	other threads:[~2008-06-12 20:52 UTC|newest]

Thread overview: 42+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2008-06-11 11:38 Enumeration representation clause surprise Markus Schoepflin
2008-06-11 12:30 ` christoph.grein
2008-06-11 12:56   ` Markus Schoepflin
2008-06-11 13:08     ` christoph.grein
2008-06-11 13:28     ` Samuel Tardieu
2008-06-11 13:48       ` Markus Schoepflin
2008-06-11 13:56         ` Samuel Tardieu
2008-06-11 14:58       ` Adam Beneschan
2008-06-11 15:23         ` Markus Schoepflin
2008-06-12  2:37           ` Randy Brukardt
2008-06-12  2:37           ` Randy Brukardt
2008-06-11 15:56         ` Samuel Tardieu
2008-06-11 19:10           ` Adam Beneschan
2008-06-11 19:59             ` Niklas Holsti
2008-06-12  1:16               ` tmoran
2008-06-12  8:27                 ` christoph.grein
2008-06-12  8:45               ` Markus Schoepflin
2008-06-12 16:43                 ` Mike Silva
2008-06-12 18:41                   ` Markus Schöpflin
2008-06-12 20:10                     ` Mike Silva
2008-06-12 20:52                       ` Simon Wright [this message]
2008-06-12 23:36                         ` Mike Silva
2008-06-13  5:49                           ` Simon Wright
2008-06-13  7:21                       ` Keith Thompson
2008-06-13 13:31                         ` Mike Silva
2008-06-13 14:45                           ` Markus Schoepflin
2008-06-13 17:52                           ` Keith Thompson
2008-06-13  9:14                       ` Jean-Pierre Rosen
2008-06-12 19:05 ` richtmyer
2008-06-12 21:26   ` Samuel Tardieu
2008-06-12 22:42     ` Adam Beneschan
2008-06-13  7:11       ` Samuel Tardieu
2008-06-13  8:27       ` christoph.grein
2008-06-13 16:21         ` Adam Beneschan
2008-06-15 19:33           ` Robert A Duff
2008-06-16 14:50             ` Adam Beneschan
2008-06-16 19:18               ` Robert A Duff
2008-06-17  6:03               ` christoph.grein
2008-06-17  7:22                 ` christoph.grein
2008-06-13  8:24     ` Peter Hermann
2008-06-13 14:47       ` Samuel Tardieu
2008-06-14 11:48         ` John B. Matthews
replies disabled

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