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.3 required=5.0 tests=BAYES_00,INVALID_MSGID autolearn=no autolearn_force=no version=3.4.4 X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 103376,65f09e2d2d4dad56 X-Google-Attributes: gid103376,public From: Nicolas Brunot Subject: Re: Representation Clauses And Freezing Date: 2000/07/18 Message-ID: <397418C7.8024A458@cadwin.com>#1/1 X-Deja-AN: 647691793 Content-Transfer-Encoding: 7bit References: <3973192E.E7337814@acm.com> X-Accept-Language: fr Content-Type: text/plain; charset=us-ascii X-Complaints-To: abuse@proxad.net X-Trace: nnrp4.proxad.net 963909812 212.27.55.236 (Tue, 18 Jul 2000 10:43:32 CEST) Organization: Guest of ProXad - France MIME-Version: 1.0 NNTP-Posting-Date: Tue, 18 Jul 2000 10:43:32 CEST Newsgroups: comp.lang.ada Date: 2000-07-18T00:00:00+00:00 List-Id: I think this has something to do with the compiler implementation hidden tag field of the tagged record. (the compiler refuses to put 'for field_01 use at 2 range 0..15' and says : component overlap tag field of "rec_type") may be the compiler implementation changes if rec_type is private may be (worse) than compilation is ok without warning, but execution crashes when rec_type is not private. Have you tested ? Anyway it's an illogic behavior (even if compatibble with RM) of the compiler to be more restrictive on a private type than on a the same visible one. Nicolas BRUNOT "Marin D. Condic" a ?crit : > I am trying to find a reasonable workaround to a problem involving > representation clauses and tagged records. I believe I am running into > problems with freezing rules. Below are two compiler listings which are > very similar. When the record type is visible, the compiler is happy. > When the record type is private, it complains. The question in my mind > is *WHY* is there some sort of restriction on this? What compiler > mission cannot be achieved unless the record is visible? Is there some > sort of workaround that would enable representation clauses on private > tagged records? (Inheritance from a rep-claused-tagged-record is its own > problem!) > > GNAT 3.12p (19990629) Copyright 1992-1999 Free Software Foundation, > Inc. > > Compiling: rep_clause_01.ads (source file time stamp: 2000-07-17 > 14:20:14) > > 1. with System ; > 2. > 3. package Rep_Clause_01 is > 4. > 5. type UInteger_16 is mod 2**16 ; > 6. for UInteger_16'Size use 16 ; > 7. > 8. type Rec_Type is tagged record > 9. Field_01 : Uinteger_16 := 0 ; > 10. Field_02 : Uinteger_16 := 0 ; > 11. Field_03 : Uinteger_16 := 0 ; > 12. end record ; > 13. > 14. private > 15. > 16. for Rec_Type use record > 17. Field_01 at 4 range 0..15 ; > 18. Field_02 at 6 range 0..15 ; > 19. Field_03 at 8 range 0..15 ; > 20. end record ; > 21. > 22. for Rec_Type'Size use 10 * System.Storage_Unit ; > 23. for Rec_Type'Alignment use 2 ; > 24. > 25. end Rep_Clause_01 ; > > 25 lines: No errors > > GNAT 3.12p (19990629) Copyright 1992-1999 Free Software Foundation, > Inc. > > Compiling: rep_clause_02.ads (source file time stamp: 2000-07-17 > 14:20:14) > > 1. > 2. with System ; > 3. > 4. package Rep_Clause_02 is > 5. > 6. type UInteger_16 is mod 2**16 ; > 7. for UInteger_16'Size use 16 ; > 8. > 9. type Rec_Type is tagged private ; > 10. > 11. private > 12. > 13. type Rec_Type is tagged record > 14. Field_01 : Uinteger_16 := 0 ; > 15. Field_02 : Uinteger_16 := 0 ; > 16. Field_03 : Uinteger_16 := 0 ; > 17. end record ; > 18. > 19. for Rec_Type use record > 20. Field_01 at 4 range 0..15 ; > 21. Field_02 at 6 range 0..15 ; > 22. Field_03 at 8 range 0..15 ; > 23. end record ; > 24. > 25. for Rec_Type'Size use 10 * System.Storage_Unit ; > | > ??? size for "Rec_Type" too small, minimum allowed is 128 > > 26. for Rec_Type'Alignment use 2 ; > | > ??? alignment for "Rec_Type" must be at least 4 > > 27. > 28. end Rep_Clause_02 ; > > MDC > -- > ====================================================================== > Marin David Condic - Quadrus Corporation - http://www.quadruscorp.com/ > Send Replies To: m c o n d i c @ q u a d r u s c o r p . c o m > Visit my web site at: http://www.mcondic.com/ > > "Nothing in the world is more dangerous than sincere ignorance and > conscientious stupidity." > > -- Martin Luther King, Jr > ======================================================================