From: Mark Wooding Date: Sat, 3 Aug 2019 15:47:15 +0000 (+0100) Subject: doc/concepts.tex: Delete `no way to discover alignment for instance' claim. X-Git-Url: https://git.distorted.org.uk/~mdw/sod/commitdiff_plain/99fca9a58949436b350c761c31390c80a33af674?hp=d9db9c73add5814057a80e9969c74419ce30e664 doc/concepts.tex: Delete `no way to discover alignment for instance' claim. Replace with a reference to the `align' class slot. --- diff --git a/doc/concepts.tex b/doc/concepts.tex index eae67aa..67dc35b 100644 --- a/doc/concepts.tex +++ b/doc/concepts.tex @@ -940,7 +940,8 @@ layout of an instance of some class~$C$ is described by the type @|struct $C$__ilayout|, and if the relevant class is known at compile time then the best way to discover the layout size is with the @|sizeof| operator. Failing that, the size required to hold an instance of $C$ is available in a slot in -$C$'s class object, as @|$C$__class@->cls.initsz|. +$C$'s class object, as @|$C$__class@->cls.initsz|. The necessary alignment, +in bytes, is provided as @|$C$__class@->cls.align|, should this be necessary. It is not in general sufficient to declare, or otherwise allocate, an object of the class type $C$. The class type only describes a single chain of the @@ -956,10 +957,6 @@ instances, so, for example, Sod doesn't make using fancy allocators which sometimes move objects around in memory any more difficult than it needs to be. -There isn't any way to discover the alignment required for a particular -class's instances at runtime; it's best to be conservative and assume that -the platform's strictest alignment requirement applies. - The following simple function correctly allocates and returns space for an instance of a class given a pointer to its class object @. \begin{prog}