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=3.8 required=5.0 tests=BAYES_00,INVALID_MSGID, RATWARE_MS_HASH,RATWARE_OUTLOOK_NONAME autolearn=no autolearn_force=no version=3.4.4 X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 103376,53e53000d1e9b814,start X-Google-Attributes: gid103376,public From: "Jonas Nygren" Subject: [Q] : Unchecked conversion Date: 1996/11/09 Message-ID: <01bbce46$0f818680$829d6482@joy.ericsson.se>#1/1 X-Deja-AN: 195493074 organization: Ericsson newsgroups: comp.lang.ada Date: 1996-11-09T00:00:00+00:00 List-Id: I have defined an IO buffer type which I intend to use for my own IO packages. The buffer type is defined as follows: subtype Byte is Integer range 0..255; type Buffer is array (Positive range <>) of Byte; Pragma Pack(Buffer); for Buffer'Component_Size use 8; I also want to be able to convert between Buffer and String types. I use Gnat and I know that the underlying data representation of Buffer and String are the same so I thought I could do an Unchecked_Conversion: function To_Buffer (S : String) return Buffer is function Convert is new Ada.Unchecked_Conversion(String, Buffer); begin return Convert(S); end To_Buffer; but Gnat gives me an error: unconstrained type "Standard.String" not allowed in unchecked conversion According to the RM95 Unchecked_Conversion should accept unconstrained types but implementations are allowed to impose limitations. My questions are: 1) Is this a Gnat(3.04a) imposed limitation on Unchecked_Conversion or is my code illegal irregardless of compiler? 2) Is there a way of doing this type conversion, save copying? /jonas