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!aioe.org!.POSTED!not-for-mail From: Victor Porton Newsgroups: comp.lang.ada Subject: Re: Allocators design flaw Date: Sat, 14 Oct 2017 19:22:26 +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:48470 Date: 2017-10-14T19:22:26+03:00 List-Id: Simon Wright wrote: > Victor Porton writes: > >> Simon Wright wrote: >> >>> Victor Porton writes: >>> >>>>> If the C struct needs alignment greater than that of the elements of >>>>> which it is composed (see the AI for example) it would have it. >>>> >>>> "it would have it"? What this sequence of English words mean? >>> >>> it would have such an alignment >>> >>> struct chrs { >>> char c[10]; >>> } >>> >>> only *needs* alignment of 1 >>> >>> struct chrs { >>> int last; >>> char c[256]; >>> } >> >> No, all C structs share the same alignment. > > I agree that malloc() will always allocate aligned on some boundary > (16-byte? 32-byte?) but that's not the same as the alignment of the > struct itself. > > See e.g. > https://en.wikipedia.org/wiki/Data_structure_alignment#Typical_alignment_of_C_structs_on_x86 I want my program to work well with every conformant Ada compiler, not just "typically" as you propose. >>> needs the alignment of int (4 on this Mac) >>> >>> (aploogies if the C isn't correct) -- Victor Porton - http://portonvictor.org