From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.eternal-september.org!eternal-september.org!.POSTED!not-for-mail From: Blady Newsgroups: comp.lang.ada Subject: Re: Pack aspect with aliased component. Date: Thu, 6 Mar 2025 21:52:44 +0100 Organization: A noiseless patient Spider Message-ID: References: MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 8bit Injection-Date: Thu, 06 Mar 2025 21:52:44 +0100 (CET) Injection-Info: dont-email.me; posting-host="3461c914102f1e66019aa7d8700dcb40"; logging-data="3303051"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX18+YvTA3OjFMDmu2fUI7U+j" User-Agent: Mozilla Thunderbird Cancel-Lock: sha1:bPcuGFlDDx/lH1MMa/ZrjkLJ4L8= Content-Language: fr, en-US In-Reply-To: Xref: news.eternal-september.org comp.lang.ada:66532 List-Id: Le 02/03/2025 à 12:33, Jeffrey R.Carter a écrit : > On 2025-03-02 10:29, Blady wrote: >> >> With the following AARM example: >> 14.e/3          {AI05-0229-1} procedure Q is >>                     use P1, P2; >>                     type Array1 is array(Integer range <>) of aliased S1 >>                        with Pack; -- warning: cannot pack aliased >> components (RM 13.2(7)) >> >> GNAT issues the warning in comment above. >> >> Why packed type couldn't have aliased components? > > This is a warning, not an error. The compiler has accepted the > declaration and you can use it. > > Remember that Pack is a suggestion to the compiler, not a requirement, > and the compiler can ignore it, or pack things less tightly than you > might like. > > An aliased component may be accessed through an alias (access value), > and that access will not know that the component has been packed, and so > access memory belonging to other components as well. For this reason, > aliased components cannot be packed. > > You can specify Component_Size for the type; the compiler must either be > able to make the components that size, or reject the declaration. > Specifying a Component_Size for an aliased component that makes the > component smaller than a stand-alone object of the type will be rejected. Thanks Jeff, your explanation seems to me clearer than the AARM ;)