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,FREEMAIL_FROM autolearn=unavailable autolearn_force=no version=3.4.4 Path: eternal-september.org!reader01.eternal-september.org!reader02.eternal-september.org!news.eternal-september.org!feeder.eternal-september.org!news.fcku.it!aioe.org!.POSTED!not-for-mail From: Victor Porton Newsgroups: comp.lang.ada Subject: Re: Allocators design flaw Date: Sun, 15 Oct 2017 00:26:28 +0300 Organization: Aioe.org NNTP Server Message-ID: References: NNTP-Posting-Host: 8U0x309/ia0QUzusgm/krA.user.gioia.aioe.org Mime-Version: 1.0 Content-Type: text/plain; charset="ISO-8859-1" Content-Transfer-Encoding: 7Bit X-Complaints-To: abuse@aioe.org User-Agent: KNode/4.14.10 X-Notice: Filtered by postfilter v. 0.8.2 Xref: news.eternal-september.org comp.lang.ada:48480 Date: 2017-10-15T00:26:28+03:00 List-Id: Simon Wright wrote: > Victor Porton writes: > >> There is nothing in Ada standard to prevent the above "new" operator >> to request 256-byte alignment of the data. (Yes, I know this does not >> happen in practice, but it is not forbidden by the RM.) >> >> If it requests such a great alignment by the C function >> *_alloc_memory() is able to do only 16-byte alignment, then my >> allocator would break the contract, that is allocate with lesser >> alignment than requested. > > Since you agree it's very unlikely that an Ada compiler would actually > do that, why not just check the requested alignment & raise PE if it's > too large? I already considered this, but: It does not seem absolutely impossible that Ada never requests alignment above the minimum alignment for allocated C structs. (And all we can know about the allocator in the C library is that it is appropriate for structs.) For example 4 bytes seems a possible alignment for C structs, but I can't be completely sure that Ada never requests 8 bytes alignment. Yes, this is unlikely, but not entirely impossible. So I have rewritten my code without using allocators at all. -- Victor Porton - http://portonvictor.org