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 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!.POSTED!not-for-mail From: Simon Wright Newsgroups: comp.lang.ada Subject: Re: Allocators design flaw Date: Sat, 14 Oct 2017 16:56:04 +0100 Organization: A noiseless patient Spider Message-ID: References: Mime-Version: 1.0 Content-Type: text/plain Injection-Info: reader02.eternal-september.org; posting-host="e53c3a1e14119dea7f561d1d98279ae1"; logging-data="24698"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1+T9l6E2kfl7VrcmxE9HbeVYrlJpJG11T8=" User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/25.3 (darwin) Cancel-Lock: sha1:ZFhskfy7Efv0Sc14F5suRry5AQo= sha1:9SYrsGeecPiYCAfgc1ReQlF7Jno= Xref: news.eternal-september.org comp.lang.ada:48468 Date: 2017-10-14T16:56:04+01:00 List-Id: 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 >> needs the alignment of int (4 on this Mac) >> >> (aploogies if the C isn't correct)