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,b9880ab5a4975a57 X-Google-Attributes: gid103376,public X-Google-Language: ENGLISH,ASCII-7-bit Path: g2news1.google.com!news1.google.com!news.glorb.com!news.zanker.org!newsfeed00.sul.t-online.de!t-online.de!newsfeed.r-kom.de!news-nue1.dfn.de!news-ber1.dfn.de!news.uni-hamburg.de!cs.tu-berlin.de!uni-duisburg.de!not-for-mail From: Georg Bauhaus Newsgroups: comp.lang.ada Subject: Re: Object with zero bits Date: Thu, 14 Oct 2004 14:55:47 +0000 (UTC) Organization: GMUGHDU Message-ID: References: <5ad0dd8a.0410130718.6a7bd161@posting.google.com> <2t5jo2F1s56mgU1@uni-berlin.de> <2t65nbF1s7981U1@uni-berlin.de> NNTP-Posting-Host: l1-hrz.uni-duisburg.de X-Trace: a1-hrz.uni-duisburg.de 1097765747 28288 134.91.1.34 (14 Oct 2004 14:55:47 GMT) X-Complaints-To: usenet@news.uni-duisburg.de NNTP-Posting-Date: Thu, 14 Oct 2004 14:55:47 +0000 (UTC) User-Agent: tin/1.5.8-20010221 ("Blue Water") (UNIX) (HP-UX/B.11.00 (9000/800)) Xref: g2news1.google.com comp.lang.ada:5201 Date: 2004-10-14T14:55:47+00:00 List-Id: Nick Roberts wrote: :> With suitable rep clauses, Boolean discriminants don't seem to consume :> space in some variant records, when the compiler can find out :-) : : Which compiler please? Would you be kind enough to post test code. This "works" with ObjectAda: package Test_02 is type Representation is (As_S, As_V); for Representation'Size use 1; type String_Access is access String; type Component (The_Representation : Representation) is record case The_Representation is when As_S => The_S : String_Access; when As_V => The_V : Natural; end case; end record; for Component use record --The_Representation at 4 range 0 .. 1; -- adds more bits The_S at 0 range 0 .. 31; The_V at 0 range 0..31; end record; OA_Component_Size: constant := 32; pragma assert (Component'Size = OA_Component_Size); generic The_Representation: Representation; package Nested is type Item is record The_Component: Component(The_Representation); end record; end Nested; package One_Or_Other is new Nested(As_V); type V_Item is new One_Or_Other.Item; pragma Assert(V_Item'Size = Component'Size); pragma Assert(V_Item'Max_Size_In_Storage_Elements = 4); Test: V_Item; pragma Assert(Test.The_Component'Position = 0); end Test_02; (The original problem was to specify represenations for a record with a component of type Component, which isn't possible because objects of type component vary in size (by definition?). Deriving a new type, type D is new T(value); where T has one discriminant does not seem to "fix" the size. -- georg